60200004 - 数列操作3

给出一个长为n的数列a1~an,以及n个操作,操作涉及区间开方,区间求和。

Input

第一行输入一个数字n(1≤n≤50 000)。 第二行输入n个整型数,第i个数字为ai。 接下来输入n行询问,每行输入4个整型数opt,l,r,c。 若opt=0,表示将位于[l,r]区间的数字都开方,对于区间中每个ai(l≤i≤r),ai←⌊√(a_i )⌋。 若opt=1,表示询问[l,r]区间中所有数字的和。

Output

对于每次询问,输出一行一个数字表示答案。

Examples

Input

4
1 2 2 3
0 1 3 1
1 1 4 4
0 1 2 2
1 1 2 4

Output

6
2
Time Limit 1 second
Memory Limit 128 MB
Discuss Stats
上一题 下一题