#include #define rep(i,n) for(int i=0;i #define VVI vector> using namespace std; int main(void){ int N,Q; cin>>N; VI A(N),S(N-23); rep(i,N)cin>>A[i]; rep(i,24)S[0]+=A[i]; for(int i=1;i>Q; VI T(Q),V(Q),ans(Q); rep(i,Q){ cin>>T[i]>>V[i]; int s=max(0,T[i]-24); int e; if(s==0)e=T[i]+1; else e=s+23; for(int j=s;j