#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
using namespace std;
#define mid ((l+r)>>1)
#define lc x<<1
#define rc x<<1|1
#define lson x<<1,l,mid
#define rson x<<1|1,mid+1,r
const int N=1e5+5;
typedef long long ll;
inline ll read(){
char c=getchar();ll x=0,f=1;
while(c<‘0‘||c>‘9‘){if(c==‘-‘)f=-1;c=getchar();}
while(c>=‘0‘&&c<=‘9‘){x=x*10+c-‘0‘;c=getchar();}
return x*f;
}
int n,Q,op,ql,qr;
struct node{
int col;
ll sum;
node():col(0),sum(0){}
}t[N<<2];
inline void merge(int x){
t[x].sum=t[lc].sum+t[rc].sum;
t[x].col=t[lc].col&t[rc].col;
}
void build(int x,int l,int r){
if(l==r){
t[x].sum=read();
if(t[x].sum==1||t[x].sum==0) t[x].col=1;
}else{
build(lson);
build(rson);
merge(x);
}
}
void segSqr(int x,int l,int r,int ql,int qr){
if(t[x].col) return;
if(l==r){
t[x].sum=(ll)sqrt(t[x].sum);
if(t[x].sum==1||t[x].sum==0) t[x].col=1;
}else{
if(ql<=mid) segSqr(lson,ql,qr);
if(mid<qr) segSqr(rson,ql,qr);
merge(x);
}
}
ll segQue(int x,int l,int r,int ql,int qr){
if(ql<=l&&r<=qr) return t[x].sum;
else{
ll ans=0;
if(ql<=mid) ans+=segQue(lson,ql,qr);
if(mid<qr) ans+=segQue(rson,ql,qr);
return ans;
}
}
int main(){
//freopen("in.txt","r",stdin);
n=read();
build(1,1,n);
Q=read();
while(Q--){
op=read();ql=read();qr=read();
if(ql>qr) swap(ql,qr);
if(op==1) printf("%lld\n",segQue(1,1,n,ql,qr));
else segSqr(1,1,n,ql,qr);
}
}