#include <bits/stdc++.h>
using namespace std;
const int N = 1E6 + 7;
vector<long long> pre[N], dis[N];
int t[N];
long long query(int s, long long h) {
  if (h <= 0) return 0;
  int p = upper_bound(begin(dis[s]), end(dis[s]), h) - begin(dis[s]);
  return p * h - pre[s][p - 1];
}
int main() {
  std::ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  int n, m;
  cin >> n >> m;
  for (int i = 2; i <= n; i++) cin >> t[i];
  for (int i = n; i >= 1; i--) {
    dis[i].emplace_back(0);
    for (int c = 0; c < 2; c++) {
      int x = 2 * i + c;
      if (x > n) continue;
      for (long long it : dis[x]) {
        dis[i].emplace_back(it + t[x]);
      }
    }
    sort(begin(dis[i]), end(dis[i]));
    int tot = dis[i].size();
    pre[i].resize(tot);
    for (int j = 1; j < tot; j++) pre[i][j] = pre[i][j - 1] + dis[i][j];
  }
  while (m--) {
    int a, h;
    long long ans = 0;
    cin >> a >> h;
    ans += query(a, h);
    while (a > 1) {
      int b = a;
      a >>= 1;
      h -= t[b];
      if (h <= 0) break;
      ans += h;
      int x = 2 * a == b ? 2 * a + 1 : 2 * a;
      if (x <= n) ans += query(x, h - t[x]);
    }
    cout << ans << '\n';
  }
  return 0;
}
