#include<bits/stdc++.h>
#define ll long long
using namespace std;
ll n,a,b,c,d,i,ma=0,A[1000001],j,D[1000001],q,k,l,r,T[1000001]={};
ll ptich(ll n)
{
ll ma=1;
ll vt=upper_bound(D+1,D+d+1,sqrt(n))-D-1;
for(ll i=1;i<=vt;i++)
{
ll fifai=0;
while(n%D[i]==0)
{
n/=D[i];
fifai++;
}
if(D[i]%2==1)
{
ll k=pow(D[i],fifai);
ma=max(ma,k);
}
}
if(n>1&&n%2==1)
{
ma=max(ma,n);
}
return ma;
}
ll ktnt(ll x)
{
ll i=2,k=sqrt(x);
while(x%i!=0&&i<=k) i++;
if(i>k&&x>1) return 1;
else return 0;
}
int main()
{
D[1]=2;
D[2]=3;
d=2;
for(i=6;i<=sqrt(1e9);i++)
{
if(ktnt(i-1)==1)
{
d++;
D[d]=i-1;
}
if(ktnt(i+1)==1)
{
d++;
D[d]=i+1;
}
}
T[0]=0;
cin>>n>>q;
for(i=1;i<=n;i++)
{
cin>>A[i];
T[i]=T[i-1]+ptich(i);
}
while(q--)
{
ll res=0;
cin>>k>>l>>r;
if(k==2)
{
for(i=l;i<=r;i++)
{
res+=A[i];
}
res+=T[r]-T[l-1];
cout<<res<<endl;
}
else
{
A[l]=r;
}
}
}
I2luY2x1ZGU8Yml0cy9zdGRjKysuaD4KI2RlZmluZSBsbCBsb25nIGxvbmcKdXNpbmcgbmFtZXNwYWNlIHN0ZDsKbGwgbixhLGIsYyxkLGksbWE9MCxBWzEwMDAwMDFdLGosRFsxMDAwMDAxXSxxLGssbCxyLFRbMTAwMDAwMV09e307CmxsIHB0aWNoKGxsIG4pCnsKCWxsIG1hPTE7CglsbCB2dD11cHBlcl9ib3VuZChEKzEsRCtkKzEsc3FydChuKSktRC0xOwoJZm9yKGxsIGk9MTtpPD12dDtpKyspCgl7CgkJbGwgZmlmYWk9MDsKCQl3aGlsZShuJURbaV09PTApCgkJewoJCQluLz1EW2ldOwoJCQlmaWZhaSsrOwoJCX0KCQlpZihEW2ldJTI9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