#include <bits/stdc++.h>
const int maxn = 1e6;
std::vector<int> d[maxn + 1];
std::vector<long long> sum[maxn + 1];
int w[maxn + 1];
int n, m;
long long solve(int u, int h) {
  int i = std::upper_bound(d[u].begin(), d[u].end(), h) - d[u].begin() - 1;
  if (0 <= i && i < d[u].size()) return (long long)(i + 1) * h - sum[u][i];
  return 0;
}
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i < n; i++) scanf("%d", &w[i]);
  for (int i = n; i >= 1; i--) {
    d[i].clear();
    int l = i << 1, r = i << 1 | 1;
    if (l <= n) {
      d[i].push_back(w[l - 1]);
      for (int j = 0; j < d[l].size(); j++) d[i].push_back(d[l][j] + w[l - 1]);
    }
    if (r <= n) {
      d[i].push_back(w[r - 1]);
      for (int j = 0; j < d[r].size(); j++) d[i].push_back(d[r][j] + w[r - 1]);
    }
    std::sort(d[i].begin(), d[i].end());
    sum[i].resize(d[i].size());
    long long pre = 0;
    for (int j = 0; j < sum[i].size(); j++) sum[i][j] = pre = pre + d[i][j];
  }
  while (m--) {
    int u, h;
    scanf("%d%d", &u, &h);
    long long ans = solve(u, h) + h;
    int flag = (u & 1) ^ 1;
    h -= w[u - 1];
    u >>= 1;
    while (h > 0 && u) {
      int v = u << 1 | flag;
      ans += h;
      if (1 <= v && v <= n && h > w[v - 1])
        ans += h - w[v - 1] + solve(v, h - w[v - 1]);
      h -= w[u - 1];
      flag = (u & 1) ^ 1;
      u >>= 1;
    }
    printf("%lld\n", ans);
  }
  return 0;
}
