Problem: There is a strip with an infinite number of cells. Cells are numbered starting with 0. Initially the cell i contains a ball with the number i.

There are n pockets located at cells a_1, …, a_n. Each cell contains at most one pocket.

Filtering is the following sequence of operations:

  * All pockets at cells a_1, …, a_n open simultaneously, which makes balls currently located at those cells disappear. After the balls disappear, the pockets close again.
  * For each cell i from 0 to ∞, if the cell i contains a ball, we move that ball to the free cell j with the lowest number. If there is no free cell j < i, the ball stays at the cell i.



Note that after each filtering operation each cell will still contain exactly one ball.

For example, let the cells 1, 3 and 4 contain pockets. The initial configuration of balls is shown below (underscores display the cells with pockets):

0 1 2 3 4 5 6 7 8 9 ... 

After opening and closing the pockets, balls 1, 3 and 4 disappear:

0  2  5 6 7 8 9 ... 

After moving all the balls to the left, the configuration looks like this:

0 2 5 6 7 8 9 10 11 12 ... 

Another filtering repetition results in the following:

0 5 8 9 10 11 12 13 14 15 ... 

You have to answer m questions. The i-th of these questions is "what is the number of the ball located at the cell x_i after k_i repetitions of the filtering operation?"

Input

The first line contains two integers n and m — the number of pockets and questions respectively (1 ≤ n, m ≤ 10^5).

The following line contains n integers a_1, …, a_n — the numbers of cells containing pockets (0 ≤ a_1 < … < a_n ≤ 10^9).

The following m lines describe questions. The i-th of these lines contains two integers x_i and k_i (0 ≤ x_i, k_i ≤ 10^9).

Output

Print m numbers — answers to the questions, in the same order as given in the input.

Example

Input

3 15
1 3 4
0 0
1 0
2 0
3 0
4 0
0 1
1 1
2 1
3 1
4 1
0 2
1 2
2 2
3 2
4 2


Output

0
1
2
3
4
0
2
5
6
7
0
5
8
9
10

Solution (in CPP):

Solution:
#include <bits/stdc++.h>
using namespace std;
int fen[100005], lson[20000005], rson[20000005], sum[20000005], t_cnt, n, q;
int arr[100005], cnt[100005], en[100005], rt[100005], rk[100005];
long long pre[100005];
inline void modify(int pos, int x) {
  for (; pos <= n; pos += pos & -pos) {
    fen[pos] += x;
  }
}
inline int query(int pos) {
  int res = 0;
  for (; pos; pos -= pos & -pos) {
    res += fen[pos];
  }
  return res;
}
inline int calc(int x) {
  int l = 1, r = n, res = n + 1;
  while (l <= r) {
    int m = l + r >> 1;
    if (query(m) > x) {
      res = m;
      r = m - 1;
    } else {
      l = m + 1;
    }
  }
  modify(res, -1);
  return res;
}
void modify(int& u, int v, int l, int r, int x) {
  u = ++t_cnt;
  lson[u] = lson[v];
  rson[u] = rson[v];
  sum[u] = sum[v] + 1;
  if (l == r) {
    return;
  }
  int m = l + r >> 1;
  if (x <= m) {
    modify(lson[u], lson[v], l, m, x);
  }
  if (x > m) {
    modify(rson[u], rson[v], m + 1, r, x);
  }
}
int query_rank(int u, int l, int r, int x) {
  if (l == r) {
    return l;
  }
  int m = l + r >> 1;
  if (sum[lson[u]] > x) {
    return query_rank(lson[u], l, m, x);
  }
  return query_rank(rson[u], m + 1, r, x - sum[lson[u]]);
}
int query_sum(int u, int l, int r, int x) {
  if (r <= x) {
    return sum[u];
  }
  int m = l + r >> 1, res = m < x ? query_sum(rson[u], m + 1, r, x) : 0;
  return query_sum(lson[u], l, m, x) + res;
}
pair<long long, int> calc(int x, int y, int k) {
  y += cnt[x] - k;
  int res = upper_bound(cnt, cnt + n, y) - cnt;
  return {(long long)res * y - pre[res], res};
}
int query_bel(int x, int k) {
  int l = 0, r = n - 1, res = -1;
  while (l <= r) {
    int m = l + r >> 1;
    if (calc(m, 0, k).first <= x) {
      res = m;
      l = m + 1;
    } else {
      r = m - 1;
    }
  }
  return res;
}
int query_pos(int x, int y, int t) {
  int l = 0, r = cnt[x + 1] - cnt[x], res = -1;
  if (x == n - 1) {
    r = y / n + t + 1;
  }
  while (l <= r) {
    int m = l + r >> 1;
    if (calc(x, m, t).first <= y) {
      res = m;
      l = m + 1;
    } else {
      r = m - 1;
    }
  }
  return res;
}
int main() {
  scanf("%d%d", &n, &q);
  for (int i = 0; i < n; i++) {
    scanf("%d", arr + i);
  }
  int st = arr[0];
  for (int i = n - 1; i >= 0; i--) {
    arr[i] -= arr[0];
  }
  for (int i = 1; i < n; i++) {
    cnt[i] = cnt[i - 1] + (arr[i] - en[i - 1]) / i;
    en[i] = arr[i] - (arr[i] - en[i - 1]) % i;
    pre[i + 1] = pre[i] + cnt[i];
  }
  for (int i = 1; i <= n; i++) {
    modify(i, 1);
  }
  for (int i = n - 1; i >= 0; i--) {
    rk[i] = calc(arr[i] - en[i]) - 1;
  }
  for (int i = 0; i < n; i++) {
    modify(rt[i + 1], rt[i], 0, n - 1, rk[i]);
  }
  while (q--) {
    int x, k;
    scanf("%d%d", &x, &k);
    if (x < st) {
      printf("%d\n", x);
      continue;
    }
    x -= st;
    int a = query_bel(x, k), b = query_pos(a, x, k);
    pair<long long, int> res = calc(a, b, k);
    int rem = x - res.first, t = query_rank(rt[res.second], 0, n - 1, rem);
    long long ans = st + en[a] + (long long)(a + 1) * b;
    if (t) {
      ans += query_sum(rt[a + 1], 0, n - 1, t - 1);
    }
    printf("%lld\n", ans);
  }
  return 0;
}