#include <bits/stdc++.h>
using namespace std;
const long long maxn = 1e6 + 10;
long long N, M, L[maxn];
vector<long long> tr[maxn], trs[maxn];
void bd(long long v) {
  long long lv = v * 2, rv = v * 2 + 1;
  int ls = 0, rs = 0;
  if (lv <= N) {
    bd(lv);
    ls = tr[lv].size();
  }
  if (rv <= N) {
    bd(rv);
    rs = tr[rv].size();
  }
  int i, j;
  i = j = 0;
  while (i < ls && j < rs) {
    if (tr[lv][i] + L[lv] < tr[rv][j] + L[rv])
      tr[v].push_back(tr[lv][i++] + L[lv]);
    else
      tr[v].push_back(tr[rv][j++] + L[rv]);
  }
  if (i < ls)
    while (i < ls) tr[v].push_back(tr[lv][i++] + L[lv]);
  if (j < rs)
    while (j < rs) tr[v].push_back(tr[rv][j++] + L[rv]);
  for (int i = 1; i < tr[v].size(); ++i)
    trs[v].push_back(trs[v][i - 1] + tr[v][i]);
}
long long cal(long long v, long long H) {
  long long l = -1, mid, r = tr[v].size() - 1, ans = 0;
  while (l < r) {
    mid = (l + r + 1) >> 1;
    if (tr[v][mid] < H)
      l = mid;
    else
      r = mid - 1;
  }
  return (l < 0) ? 0LL : (H * (l + 1) - trs[v][l]);
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> N >> M;
  for (int i = 2; i <= N; ++i) cin >> L[i];
  for (int i = 1; i <= N; ++i) tr[i].push_back(0), trs[i].push_back(0);
  bd(1);
  while (M--) {
    long long A, H;
    cin >> A >> H;
    long long ans = 0, v = A, cur = 0;
    ans += cal(v, H);
    while (v >= 2) {
      cur += L[v];
      if (v & 1LL) {
        v >>= 1LL;
        long long lv = v * 2;
        if (H > cur) ans += H - cur;
        if (lv <= N) ans += cal(lv, H - cur - L[lv]);
      } else {
        v >>= 1LL;
        long long rv = v * 2 + 1;
        if (H > cur) ans += H - cur;
        if (rv <= N) ans += cal(rv, H - cur - L[rv]);
      }
    }
    cout << ans << '\n';
  }
  return 0;
}
