#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define IO ios::sync_with_stdio(false);cin.tie(0)

int main() {
    //freopen("in.txt", "r", stdin);
    int n, q, k; cin >> n >> q >> k;
    vector<int> a(n + 5), d(n + 5);
    for(int i = 1; i <= n; ++i) {
        cin >> a[i];
        d[i] = a[i] - a[i - 1];
    }
    while(q--) {
        int l, r; cin >> l >> r;
        cout << 2 * (a[r] - a[l]) + a[l] - 1 + k - a[r] - 2 * (r - l) << '\n';
    }

    return 0;
}
