#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cctype>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm> 
#include <functional>
#include <unordered_map>
#include <unordered_set>
#include  <ctime>
#include <iomanip>
#include <bitset>
#include <assert.h>   
using namespace std;
 
#define int                   long long int
#define uint                  unsigned long long int
#define loop(i,a,b)           for(int i=(int)a;i<(int)b;++i)
#define rloop(i,a,b)          for(int i=(int)a;i<=(int)b;++i)
#define loopl(i,a,b)          for(int i=(int)a;i<(int)b;++i)
#define loopr(i,a,b)          for(int i=(int)a;i>=(int)b;--i)
#define count_1(n)            __builtin_popcountint(n)
#define pb                    push_back
#define eb                    emplace_back
#define ab(a)                 (a<0)?(-1*a):a
#define pc                    putchar
#define gc                    getchar
#define mset(a,b,c)           loop(i,0,b) a[i]=c
#define mp                    make_pair
#define itoc(c)               ((char)(((int)'0')+c))
#define aint(p)                p.begin(),p.end()
#define max(x,y)              ((x>y)?x:y)
#define min(x,y)              ((x<y)?x:y)
#define mid(s,e)              (s+(e-s)/2)
#define vi                    vector<int>
#define vvi                   vector<vector<int>>

const int MOD = 1e9 + 7;
 
int modpow(int a, int b, int mod) { int res = 1; for (; b; b >>= 1) { if (b & 1)res = res * a; res %= mod; a = a * a; a %= mod; }return res; }
int p(int a, int b) { int res = 1; for (; b; b >>= 1) { if (b & 1)res = res * a; a = a * a; }return res; }


void testcases() {
    int n,q,k; cin>>n>>q>>k;
    vi a(n);
    loop(i,0,n) cin>>a[i];
    vi b(n);
    if(n > 1) b[0] = a[1] - 1;
    if(n > 1) b[1] = k-a[0];
    loop(i,1,n-1) {
        b[i] = a[i+1] - a[i-1] - 1;
    }
    loop(i,1,n) {
        b[i] += b[i-1];
    }
    while(q--) {
        int x,y; cin >> x>>y; x--; y--;
        if(x == y) { cout << k-1 << "\n"; continue; }
        int ans = b[y-1] - b[x];
        //cout << ans << "\n";
        ans += (k-a[y-1]);
        ans += (a[x+1]-1);
        ans -= y-x+1;
        cout << ans << "\n";
    }
}   
 
int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    /* code */ 
    int t; 
    // cin >> t;
    t = 1;
    while(t--) { testcases(); }
    /* end code */
}