#include <iostream>
using namespace std;
int main()
{
int n; cin >> n;
int help = 0;
int arr1[n];
for ( int i = 0 ; i < n ; i ++ )
{
cin >> arr1[i];
help += arr1[i];
arr1[i] = help;
}
int sum = 0;
int x , y;
while ( true )
{
cin >> x >> y;
if ( x == 0 )
{
sum = arr1[y];
cout << sum;
}
else if ( x > 0 )
{
sum = arr1[y] - arr1[x - 1];
cout << sum;
}
}
return 0;
}