#include <bits/stdc++.h>
using namespace std;
long long mod = 1e9 + 7;
template <typename T>
T gcd(T a, T b) {
  if (a < b) swap(a, b);
  if (b == 0) return a;
  return gcd(b, a % b);
}
int set_bits(long long n) {
  long long ans = 0;
  while (n > 0) {
    if (n % 2) ans++;
    n /= 2;
  }
  return ans;
}
long long no_factors(long long n) {
  if (n == 1) return 1;
  long long ans = 2;
  for (int i = 2; i < sqrt(n); i++) {
    if (n % i == 0) ans += 2;
  }
  if (sqrt(n) == (int)sqrt(n)) ans++;
  return ans;
}
class pairs {
 public:
  long long x, y;
};
class solution {
  long long n;
  vector<long long> a;

 public:
  solution() {
    cin >> n;
    a.resize(n);
    for (int i = 0; i < n; i++) cin >> a[i];
    long long q, sum = accumulate(a.begin(), a.end(), 0);
    cin >> q;
    while (q--) {
      long long b1, b2;
      cin >> b1 >> b2;
      sum += b2 - b1;
      cout << sum << endl;
    }
  }
};
int main() {
  solution s;
  return 0;
}
