#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
LL A[100012];
int L[100012];
int R[100012];
LL tree[100012];
LL query(int idx)
{
LL ret = 0;
for(idx+=1;idx;idx-=idx&-idx)
ret+=tree[idx];
return ret;
}
void update(int idx , LL val)
{
for(idx+=1;idx<=100011;idx+=idx&-idx)
tree[idx]+=val;
}
int main()
{
ios::sync_with_stdio(0);cin.tie(0);
int N ,e = 1;
while(cin>>N)
{
cout<<"Case #"<<e<<":\n";
int Q, i , x , y , type;
for(i=0;i<100012;++i)tree[i] = 0;
set < int > indices;
for(i=0;i<N;++i)
{
cin>>A[i];
indices.insert(i);
L[i] = i-1;
R[i] = i+1;
update(i,A[i]);
// cout<<A[i]<<" "<<query(i)-query(i-1)<<'\n';
}
// cout<<endl;
cin>>Q;
int save;
for(;Q;--Q)
{
cin>>type>>x>>y;
--x;--y;
if(x>y)swap(x,y);
if(!type)
{
auto it = indices.lower_bound(x);
if(it==indices.end())continue;
int strt=*it;
while(strt<=y)
{
update(strt,-A[strt]);
A[strt] = (LL)sqrt(A[strt]);
update(strt,A[strt]);
if(A[strt]<=1)
{
if(L[strt]!=-1)
R[L[strt]]=R[strt];
if(R[strt]!=N)
L[R[strt]]=L[strt];
auto jt = indices.lower_bound(strt);
indices.erase(jt);
}
strt = R[strt];
}
}
else
cout<<query(y)-query(x-1)<<'\n';
}
cout<<'\n';++e;
// return 0;
}
return 0;
}
I2luY2x1ZGU8Yml0cy9zdGRjKysuaD4KdXNpbmcgbmFtZXNwYWNlIHN0ZDsKdHlwZWRlZiBsb25nIGxvbmcgTEw7CkxMICAgQVsxMDAwMTJdOwppbnQgICBMWzEwMDAxMl07CmludCAgIFJbMTAwMDEyXTsKTEwgdHJlZVsxMDAwMTJdOwpMTCBxdWVyeShpbnQgaWR4KQp7CiAgICBMTCByZXQgPSAwOwogICAgZm9yKGlkeCs9MTtpZHg7aWR4LT1pZHgmLWlkeCkKICAgICAgICByZXQrPXRyZWVbaWR4XTsKICAgIHJldHVybiByZXQ7Cn0KCnZvaWQgdXBkYXRlKGludCBpZHggLCBMTCB2YWwpCnsKICAgIGZvcihpZHgrPTE7aWR4PD0xMDAwMTE7aWR4Kz1pZHgmLWlkeCkKICAgICAgICB0cmVlW2lkeF0rPXZhbDsKfQoKaW50IG1haW4oKQp7CgogICAgaW9zOjpzeW5jX3dpdGhfc3RkaW8oMCk7Y2luLnRpZSgwKTsKICAgIGludCBOICxlID0gMTsKICAgIHdoaWxlKGNpbj4+TikKICAgIHsKICAgICAgICBjb3V0PDwiQ2FzZSAjIjw8ZTw8IjpcbiI7CiAgICAgICAgaW50IFEsIGkgLCB4ICwgeSAsIHR5cGU7CiAgICAgICAgZm9yKGk9MDtpPDEwMDAxMjsrK2kpdHJlZVtpXSA9IDA7CiAgICAgICAgc2V0IDwgaW50ID4gaW5kaWNlczsKICAgICAgICBmb3IoaT0wO2k8TjsrK2kpCiAgICAgICAgewogICAgICAgICAgICBjaW4+PkFbaV07CiAgICAgICAgICAgIGluZGljZXMuaW5zZXJ0KGkpOwogICAgICAgICAgICBMW2ldID0gaS0xOwogICAgICAgICAgICBSW2ldID0gaSsxOwogICAgICAgICAgICB1cGRhdGUoaSxBW2ldKTsKLy8gICAgICAgICAgICBjb3V0PDxBW2ldPDwiICI8PHF1ZXJ5KGkpLXF1ZXJ5KGktMSk8PCdcbic7CiAgICAgICAgfQovLyAgICAgICAgY291dDw8ZW5kbDsKICAgICAgICBjaW4+PlE7CiAgICAgICAgaW50IHNhdmU7CiAgICAgICAgZm9yKDtROy0tUSkKICAgICAgICB7CgogICAgICAgICAgICBjaW4+PnR5cGU+Png+Pnk7CiAgICAgICAgICAgIC0teDstLXk7CiAgICAgICAgICAgIGlmKHg+eSlzd2FwKHgseSk7CgogICAgICAgICAgICBpZighdHlwZSkKICAgICAgICAgICAgewogICAgICAgICAgICAgICAgYXV0byBpdCA9IGluZGljZXMubG93ZXJfYm91bmQoeCk7CiAgICAgICAgICAgICAgICBpZihpdD09aW5kaWNlcy5lbmQoKSljb250aW51ZTsKICAgICAgICAgICAgICAgIGludCBzdHJ0PSppdDsKICAgICAgICAgICAgICAgIHdoaWxlKHN0cnQ8PXkpCiAgICAgICAgICAgICAgICB7CiAgICAgICAgICAgICAgICAgICAgdXBkYXRlKHN0cnQsLUFbc3RydF0pOwogICAgICAgICAgICAgICAgICAgIEFbc3RydF0gPSAoTEwpc3FydChBW3N0cnRdKTsKICAgICAgICAgICAgICAgICAgICB1cGRhdGUoc3RydCxBW3N0cnRdKTsKICAgICAgICAgICAgICAgICAgICBpZihBW3N0cnRdPD0xKQogICAgICAgICAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgICAgICAgICAgaWYoTFtzdHJ0XSE9LTEpCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBSW0xbc3RydF1dPVJbc3RydF07CiAgICAgICAgICAgICAgICAgICAgICAgIGlmKFJbc3RydF0hPU4pCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBMW1Jbc3RydF1dPUxbc3RydF07CiAgICAgICAgICAgICAgICAgICAgICAgIGF1dG8ganQgPSBpbmRpY2VzLmxvd2VyX2JvdW5kKHN0cnQpOwoKICAgICAgICAgICAgICAgICAgICAgICAgaW5kaWNlcy5lcmFzZShqdCk7CiAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIHN0cnQgPSBSW3N0cnRdOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICB9CiAgICAgICAgICAgIGVsc2UKICAgICAgICAgICAgICAgIGNvdXQ8PHF1ZXJ5KHkpLXF1ZXJ5KHgtMSk8PCdcbic7CiAgICAgICAgfQogICAgICAgIGNvdXQ8PCdcbic7KytlOwovLyAgICAgICAgcmV0dXJuIDA7CiAgICB9CiAgICByZXR1cm4gMDsKfQo=