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

#define ll long long

void solve() {
    ll n, q, k; cin >> n >> q >> k;
    vector<ll> A(n);
    for (ll &a : A)
        cin >> a;
    vector<ll> P(n);
    if (n > 1)
        P[0] = A[1] - 2;
    for (int i = 1; i < n - 1; i++) {
        P[i] = A[i + 1] - A[i - 1] - 2;
        if (i)
            P[i] += P[i - 1];
    }
    P[n - 1] = k - A[n - 1];
    if (n > 1)
        P[n - 1] += P[n - 2];
    // for (int i = 0; i < n; i++)
    //     cout << P[i] << " ";
    // cout << endl;
    auto f = [&](int l, int r) {
        if (l == r) {
            return k - 1;
        }
        ll ans = P[r - 1] - P[l];
        ans += A[l + 1] - 2;
        ans += k - A[r - 1] - 1;
        // cout << l << " " << r << " " << P[r - 1] - P[l] << " " << A[l + 1] - 2 << " " << k - A[r - 1] - 1 << endl;
        return ans;
    };
    while (q--) {
        int l, r; cin >> l >> r;
        l--, r--;
        cout << f(l, r) << '\n';
    }
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    // int t; cin >> t;
    // while (t--)
        solve();
    return 0;
}