#include <bits/stdc++.h>
using namespace std;
#define ll long long


int main()
{
    
        ll n, q, k;
        cin>>n>>q>>k;

        ll arr[n];
        for(int i=0; i<n; i++)
        {
            cin>>arr[i];
        }

        while(q--)
        {
            int l,r;
            cin>>l>>r;
            l--;
            r--;
            if(l == r)cout<<k-1<<endl;
            else
            {
                ll sum = 2 * (arr[r] - arr[l] - (r - l)) + arr[l] - 1 + k - arr[r];
                cout<<sum<<endl;
            }
        }

    
}



















