#include <iostream>
using namespace std;
int main()
{
    int n;   cin >> n;
    int arr1[n] , arr2[n];
    for ( int i = 0 ; i < n ; i ++ )
    {
        cin >> arr1[i];
        arr2[i] = 0;
    }

    for ( int i = 0 ; i < n ; i ++ )
    {
        arr2[i] += arr1[i];
    }

    int sum = 0;
    int x , y;
    while ( true )
    {
        cin >> x >> y;

        if ( x == 0 )
        {
            sum = arr2[y];
            cout << sum;
        }

        else if ( x > 0 )
        {
            sum = arr2[y] - arr2[x - 1];
            cout << sum;
        }
    }

    return 0;
}