#include <bits/stdc++.h>
#define ll long long
#define pii pair<int,int>
#define vec vector
using namespace std;

int main() {
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	#ifdef LOCAL
//		freopen("in1.txt", "r", stdin);
//		freopen("in1.txt", "w", stdout);
	#endif
	ll n, q, k;
	cin >> n >> q >> k;
	vec<ll> a(n), pref(n);
	for (ll &x : a) cin >> x;
	for (int i=1; i<n-1; i++) pref[i] = pref[i-1] + a[i]-a[i-1]-1 + a[i+1]-a[i]-1;
	ll l, r, res;
	while (q--) {
		cin >> l >> r; --l; --r;
		if (l == r) cout << k-1 << '\n';
		else {
			res = max(0ll, pref[r-1] - pref[l]);
			res += a[l+1] - 2;
			res += k - a[r-1] - 1;
			cout << res << '\n';
		}
	}
}