#include<bits/stdc++.h>
using namespace std;
#define int long long
int tree[100005*4];
int lazy[100005*4];
int s[100005*4];
int n,m;
void build(int node,int l,int r){
if(l==r){
tree[node]=0;
return ;
}
int mid=(l+r)>>1;
build(node*2,l,mid);
build(node*2+1,mid+1,r);
tree[node]=tree[node*2]+tree[node*2+1];
}
void pushdown(int node,int x,int y){
if(lazy[node]){
lazy[node<<1]+=lazy[node];
lazy[node<<1|1]+=lazy[node];
tree[node<<1]+=lazy[node]*x;
tree[node<<1|1]+=lazy[node]*y;
lazy[node]=0;
}
}
int query(int node,int l,int r,int L,int R){
if(l>=L&&r<=R){
return tree[node];
}
int mid=(l+r)>>1;
pushdown(node,mid-l+1,r-mid);
int ans=0;
if(L<=mid){
ans+=query(node<<1,l,mid,L,R);
}
if(R>mid){
ans+=query(node<<1|1,mid+1,r,L,R);
}
return ans;
}
void update(int node,int l,int r,int L,int R,int val){
if(l>=L&&r<=R){
tree[node]=(r-l+1)*val;
lazy[node]+=val;
return ;
}
int mid=l+r>>1;
pushdown(node,mid-l+1,r-mid);
if(L<=mid){
update(node<<1,l,mid,L,R,val);
}
if(R>mid){
update(node<<1|1,mid+1,r,L,R,val);
}
tree[node]=tree[node*2]+tree[node*2+1];
}
signed main(){
while(cin>>n){
for(int i =1;i<=n;i++){
cin>>s[i];
}
cin>>m;
int hh=0,h1=0,w1;
while(m--){
int l,r;
cin>>l>>r;
hh=max(hh+h1,s[l]);
w1=l;
h1=r;
cout<<hh<<endl;
}
}
return 0;
}
645A - Amity Assessment | 1144A - Diverse Strings |
1553B - Reverse String | 1073A - Diverse Substring |
630N - Forecast | 312B - Archer |
34D - Road Map | 630I - Parking Lot |
160B - Unlucky Ticket | 371B - Fox Dividing Cheese |
584B - Kolya and Tanya | 137B - Permutation |
550C - Divisibility by Eight | 5A - Chat Servers Outgoing Traffic |
615A - Bulbs | 5B - Center Alignment |
549A - Face Detection | 535B - Tavas and SaDDas |
722C - Destroying Array | 366A - Dima and Guards |
716B - Complete the Word | 1461C - Random Events |
1627A - Not Shading | 141B - Hopscotch |
47B - Coins | 1466C - Canine poetry |
74A - Room Leader | 1333D - Challenges in school №41 |
1475B - New Year's Number | 461A - Appleman and Toastman |