sum
Sum
http://www.nowcoder.com/questionTerminal/e3fd1913640c4479b53076defdb0cb44
include
include
include
using namespace std;
#define ll long long
const int mod=1e9+7;
const int maxn=1e5+100;
int a[maxn],c[35][maxn];
int n,m;
void add(int q,int x,int k){
while(x<=n){
c[q][x]+=k;
x+=x&(-x);
}
}
int sum(int q,int x){
int ret=0;
while(x>0){
ret+=c[q][x];
x-=x&(-x);
}
return ret;
}
int query(int q,int x,int y){
return sum(q,y)-sum(q,x-1);
}
ll f(ll a,ll b){
ll res=1;
while(b){
if(b&1)res=ares%mod;
a=(a*a)%mod;
b>>=1;
}
return res%mod;
}
int main(){
scanf("%d",&n);
for(int i=1;i<=n;i++){
scanf("%d",&a[i]);
int temp=a[i],q=0;
while(temp){
if(temp&1)add(q,i,1);
temp>>=1;
q++;
}
}
scanf("%d",&m);
while(m--){
int num,x,y;
scanf("%d%d%d",&num,&x,&y);
if(num==1){
int temp=a[x],q=0;
while(temp){
if(temp&1)add(q,x,-1);
temp>>=1;
q++;
}
temp=y,q=0;
while(temp){
if(temp&1)add(q,x,1);
temp>>=1;
q++;
}
a[x]=y;
}else if(num==2){
ll ans=0;
for(int j=0;j<32;j++){
ans=(ans+(f(2,query(j,x,y))-1)%mod(1<<j))%mod;
}
cout<<ans<<endl;
}
}
return 0;
}