#include <bits/stdc++.h>   using namespace std;   int main() {     int n;     cin >> n;     vector<long long int> s(n);     for (int i = 0; i < n; ++i) cin >> s[i];     int q;     cin >> q;     sort(s.begin(), s.end());     int slope0 = 1;     for (int i = 1; i < n; ++i)       if (s[i] != s[i - 1]) ++slope0;     map<long long int, int> freq;     for (int i = 1; i < n; ++i) {       long long int delta = s[i] - s[i - 1];       if (delta == 0) continue;       delta--;       if (freq.find(delta) == freq.end())         freq[delta] = 1;       else         freq[delta] = freq[delta] + 1;     }     map<long long int, int> slope;     map<long long int, long long int> obj;     long long int prev = slope0;     for (map<long long int, int>::iterator it = freq.begin(); it != freq.end();          ++it) {       slope[it->first] = prev - it->second;       prev = prev - it->second;     }     if (slope.find(0) == slope.end()) slope[0] = slope0;     for (map<long long int, int>::iterator it = slope.begin();          it != slope.end();) {       if (it->first == 0) obj[0] = slope0;       long long int y0 = obj[it->first];       long long int change = it->second;       long long int base = it->first;       ++it;       if (it != slope.end()) obj[it->first] = y0 + change * (it->first - base);     }     for (int i = 0; i < q; ++i) {       long long int l, r;       cin >> l >> r;       map<long long int, long long int>::iterator it = obj.lower_bound(r - l);       if (it->first == (r - l))         cout << it->second <<    ;       else {         it--;         long long int ans =             obj[it->first] + (r - l - it->first) * slope[it->first];         cout << ans <<    ;       }     }     cout <<   n ;     return 0;   }   