#include <bits/stdc++.h>
using namespace std;
const int INF = 2147483647;
const int mod = 1e9 + 7;
int n, L[1000005];
vector<int> v[1000005];
vector<long long> s[1000005];
void dfs1(int x, int u, int d) {
  v[x].emplace_back(d);
  if (u * 2 <= n) dfs1(x, u * 2, d + L[u * 2]);
  if (u * 2 + 1 <= n) dfs1(x, u * 2 + 1, d + L[u * 2 + 1]);
}
int main() {
  int m;
  scanf("%d%d", &n, &m);
  for (int i = 2; i <= n; i++) scanf("%d", &L[i]);
  for (int i = 1; i <= n; i++) {
    dfs1(i, i, 0);
    sort(v[i].begin(), v[i].end());
    for (int j = 0; j < v[i].size(); j++) {
      s[i].emplace_back(v[i][j]);
      if (j) s[i][j] += s[i][j - 1];
    }
  }
  while (m--) {
    int x, h;
    scanf("%d%d", &x, &h);
    long long ans = 0;
    int cnt = 0;
    int k = upper_bound(v[x].begin(), v[x].end(), h) - v[x].begin();
    if (k) {
      ans += s[x][k - 1];
      cnt += k;
    }
    int now = 0;
    while (x > 1) {
      int nx = x / 2;
      now += L[x];
      if (now > h) break;
      cnt++;
      ans += now;
      if ((x ^ 1) <= n) {
        k = upper_bound(v[x ^ 1].begin(), v[x ^ 1].end(), h - now - L[x ^ 1]) -
            v[x ^ 1].begin();
        if (k) {
          ans += (s[x ^ 1][k - 1] + (long long)(now + L[x ^ 1]) * k);
          cnt += k;
        }
      }
      x = nx;
    }
    printf("%lld\n", (long long)h * cnt - ans);
  }
  return 0;
}
