import
java.util.*;
import
java.util.stream.*;
class
Program {
static
int
MAX =
100
;
static
int
[] BIT =
new
int
[MAX +
1
];
static
class
queries {
public
int
type, l, r;
public
queries(
int
t_val,
int
l_val,
int
r_val)
{
type = t_val;
l = l_val;
r = r_val;
}
}
static
void
update(
int
x,
int
val,
int
n) {
for
(; x <= n; x += x & -x) {
BIT[x] += val;
}
}
static
int
sum(
int
x) {
int
s =
0
;
for
(; x >
0
; x -= x & -x) {
s += BIT[x];
}
return
s;
}
static
void
answerQueries(
int
[] arr, queries[] que,
int
n,
int
q) {
HashSet<Integer> s =
new
HashSet<Integer>();
for
(
int
i =
1
; i < n; i++) {
if
(arr[i] >
1
)
s.add(i);
update(i, arr[i], n);
}
for
(
int
i =
0
; i < q; i++) {
if
(que[i].type ==
1
) {
while
(
true
) {
final
var val = que[i].l;
Stream<Integer> st = s.stream().filter(x -> x >= val);
int
it = st.findFirst().orElse(
0
);
if
(it ==
0
|| it > que[i].r)
break
;
que[i].l = it;
update(it, (
int
)Math.sqrt(arr[it]) - arr[it], n);
arr[it] = (
int
)Math.sqrt(arr[it]);
if
(arr[it] ==
1
)
s.remove(it);
que[i].l++;
}
}
else
{
System.out.println(sum(que[i].r) - sum(que[i].l -
1
));
}
}
}
public
static
void
main(String[] args) {
int
q =
4
;
int
[] arr = {
0
,
4
,
5
,
1
,
2
,
4
};
int
n = arr.length;
queries[] que =
new
queries[q +
1
];
que[
0
] =
new
queries(
2
,
1
,
5
);
que[
1
] =
new
queries(
1
,
1
,
2
);
que[
2
] =
new
queries(
1
,
2
,
4
);
que[
3
] =
new
queries(
2
,
1
,
5
);
answerQueries(arr, que, n, q);
}
}