#include<iostream>
#include<cstdio>
#include<cmath>
using namespace std;
int a[1000];
int sum[1000];
int n;
int c(int x)
{ return x&(x^(x-1));
}
void change(int x,int add)
{ while(x<=n)
{sum[x]=sum[x]+add;
x=x+c(x);
}
}
int query(int x)
{ int ans=0;
while(x>0)
{ ans=ans+sum[x];
x=x-c(x);
}
return ans;
}
int main()
{ cin>>n;
for(int i=1;i<=n;i++)
{cin>>a[i];
change(i,a[i]);
}
while(1==1)
{ int x,y;
cin>>x>>y;
cout<<query(y)-query(x-1)<<endl;
}
return 0;
}
#include<cstdio>
#include<cmath>
using namespace std;
int a[1000];
int sum[1000];
int n;
int c(int x)
{ return x&(x^(x-1));
}
void change(int x,int add)
{ while(x<=n)
{sum[x]=sum[x]+add;
x=x+c(x);
}
}
int query(int x)
{ int ans=0;
while(x>0)
{ ans=ans+sum[x];
x=x-c(x);
}
return ans;
}
int main()
{ cin>>n;
for(int i=1;i<=n;i++)
{cin>>a[i];
change(i,a[i]);
}
while(1==1)
{ int x,y;
cin>>x>>y;
cout<<query(y)-query(x-1)<<endl;
}
return 0;
}