#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;
const int MAXN = 1e6 + 10;
int n, m, w[MAXN];
vector<long long> d[MAXN];
vector<long long> s[MAXN];
void init() {
  for (int i = n; i >= 1; i--) {
    d[i].push_back(0);
    if (i * 2 <= n) {
      for (auto dist : d[i * 2]) {
        d[i].push_back(dist + w[i * 2 - 1]);
      }
    }
    if ((i * 2 + 1) <= n) {
      for (auto dist : d[i * 2 + 1]) {
        d[i].push_back(dist + w[i * 2]);
      }
    }
    sort(d[i].begin(), d[i].end());
    int j = 0;
    for (auto dist : d[i]) {
      if (j)
        s[i].push_back(s[i][j - 1] + dist);
      else
        s[i].push_back(dist);
      j++;
    }
  }
}
long long work(int x, int h) {
  int p = lower_bound(d[x].begin(), d[x].end(), h) - d[x].begin();
  return (long long)p * h - s[x][p - 1];
}
int main() {
  scanf("%d%d", &n, &m);
  memset(w, INF, sizeof(w));
  for (int i = 1; i < n; i++) scanf("%d", &w[i]);
  init();
  int x, h;
  while (m--) {
    scanf("%d%d", &x, &h);
    long long ans = work(x, h);
    if (x != 1) {
      while (1) {
        if (h - w[x - 1] - w[(x ^ 1) - 1] > 0)
          ans += work(x ^ 1, h - w[x - 1] - w[(x ^ 1) - 1]);
        h = h - w[x - 1];
        if (h <= 0) break;
        ans += h;
        x = x / 2;
        if (x == 1) break;
      }
    }
    printf("%I64d\n", ans);
  }
}
