#include <bits/stdc++.h>
using namespace std;
template <class T>
inline T checkmin(T &a, T b) {
  return (a < b) ? a : a = b;
}
template <class T>
inline T checkmax(T &a, T b) {
  return (a > b) ? a : a = b;
}
template <class T>
T GCD(T a, T b) {
  if (a < 0) return GCD(-a, b);
  if (b < 0) return GCD(a, -b);
  return (a == 0) ? b : GCD(b % a, a);
}
template <class T>
T LCM(T a, T b) {
  if (a < 0) return LCM(-a, b);
  if (b < 0) return LCM(a, -b);
  return (a == 0 || b == 0) ? 0 : a / GCD(a, b) * b;
}
template <class T>
inline T sqr(T X) {
  return X * X;
}
namespace Poor {
const int MaxiN = 100005;
int N, M;
deque<pair<int, long long> > Q;
long long Get(int W) {
  long long Result = 0, Last = 0;
  while (W > 0) {
    W -= Q.front().first;
    Last = Q.front().second;
    checkmax(Result, Last);
    Q.pop_front();
  }
  if (W < 0) Q.push_front(make_pair(-W, Last));
  return Result;
}
void Run() {
  Q.clear();
  scanf("%d", &N);
  for (int i = 0; i < N; ++i) {
    int H;
    scanf("%d", &H);
    Q.push_back(make_pair(1, H));
  }
  scanf("%d", &M);
  for (int i = 0; i < M; ++i) {
    int W, H;
    scanf("%d%d", &W, &H);
    long long Result = Get(W);
    cout << Result << '\n';
    Q.push_front(make_pair(W, Result + H));
  }
}
}  // namespace Poor
int main() {
  Poor::Run();
  return 0;
}
