#include <iostream>
#include <string>
#include <cstring>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <algorithm>
#include <map>
#include <fstream>
#include <bitset>
#include <unordered_map>
#include <stack>
#include <list>

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef map<int, int> mii;
typedef map<int, string> mis;
typedef map<string, int> msi;
typedef set<int> si;
typedef set<ll> sl;
typedef map<ll, ll> mll;
typedef queue<int> qi;
typedef queue<ii> qii;
typedef vector<string> vs;
typedef pair<ll, ll> iil;
typedef priority_queue<int> pqi;
typedef priority_queue<ii> pqii;
typedef priority_queue<ll> pqil;
typedef priority_queue<iil> pqiil;
typedef vector<iil> viil;
typedef vector<vi> vvi;
typedef long double ld;
typedef pair<int, ii> iii;
typedef pair<iil, ll> iiil;
typedef vector<pair<pair<int,int>,int> > viii;
typedef vector<pair<pair<ll,ll>,ll> > viiil;
typedef vector<vl> vvl;

#define pb push_back
#define mp make_pair
#define rep(i, n) for (int i = 0 ; i < n ; i++)
#define rrep(i, m, n) for (int i = m ; i < n ; i++)
#define per(i, n) for (int i = n - 1 ; i >= 0 ; i--)
#define perr(i, m, n) for (int i = n - 1 ; i >= m ; i--)
#define INF 2000000000

ll MOD = 1000000007;

void solve() {
    
    ll n, q, k;
    cin >> n >> q >> k;
    
    vl a(n+2);
    rep(i, n) cin >> a[i+1];
    a[0] = 0;
    a[n+1] = k+1;
    
    vl l;
    vl r;
    
    rep(i, n) {
        l.pb(max(0LL, a[i+1] - a[i] - 1));
        r.pb(max(0LL, a[i+2] - a[i+1] - 1));
    }
    
    vl lp;
    vl rp;
    lp.pb(0);
    rp.pb(0);
    
    rep(i, n) {
        lp.pb(lp[lp.size()-1] + l[i]);
        rp.pb(rp[rp.size()-1] + r[i]);
    }
    
    /*rep(i, n) cout << l[i] << " ";
    cout << endl;
    rep(i, n) cout << r[i] << " ";
    cout << endl;*/
    
    rep(i, q) {
        int x, y;
        cin >> x >> y;
        
        int bt = rp[y-1] - rp[x-1] + lp[y] - lp[x];
        int end = a[x] - 1 + k - a[y];
        
        cout << bt + end << '\n';
        //cout << bt << " " << end << endl;
    }
    
}

void querySolve() {
    int t;
    cin >> t;
    for (int i = 0 ; i < t ; i++) {
        solve();
    }
}

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    
    solve();
    //querySolve();
}
