#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 5;
std::vector<int> a[N];
std::vector<long long> b[N];
int l[N];
long long get(int x, int y) {
  int ans = lower_bound(a[x].begin(), a[x].end(), y) - a[x].begin();
  return 1ll * ans * y - b[x][ans];
}
int main() {
  int n, m;
  cin >> n >> m;
  for (int i = 2; i <= n; i++) scanf("%d", l + i);
  int x, y;
  for (int i = 2; i <= n; i++) {
    int tmp = 0;
    x = i;
    while (x != 1) {
      tmp += l[x];
      x >>= 1;
      a[x].push_back(tmp);
    }
  }
  for (int i = 1; i <= n; i++) {
    long long tmp = 0;
    sort(a[i].begin(), a[i].end());
    b[i].push_back(0);
    for (int j = 0; j < a[i].size(); j++) {
      tmp += a[i][j];
      b[i].push_back(tmp);
    }
  }
  long long ans;
  for (int i = 0; i < m; i++) {
    scanf("%d%d", &x, &y);
    ans = y + get(x, y);
    while (x != 1) {
      int fa = x / 2;
      if (y < l[x]) break;
      y -= l[x];
      ans += y;
      if (x == fa * 2 && y >= l[fa * 2 + 1] && fa * 2 + 1 <= n) {
        ans += y - l[fa * 2 + 1];
        ans += get(fa * 2 + 1, y - l[fa * 2 + 1]);
      } else if (x == fa * 2 + 1 && y >= l[fa * 2]) {
        ans += y - l[fa * 2];
        ans += get(fa * 2, y - l[fa * 2]);
      }
      x = fa;
    }
    printf("%I64d\n", ans);
  }
  return 0;
}
