#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e6 + 5;
int len[maxn];
int tmp[maxn];
int vis[maxn];
vector<int> st[maxn];
vector<long long> sst[maxn];
int n, q;
void Merge(int v, int u) {
  int l1 = st[v].size(), l2 = st[u].size();
  int k = 0, i = 0, j = 0, add = len[u];
  while (i < l1 && j < l2) {
    if (st[v][i] < st[u][j] + add)
      tmp[k++] = st[v][i++];
    else
      tmp[k++] = st[u][j++] + add;
  }
  while (i < l1) tmp[k++] = st[v][i++];
  while (j < l2) tmp[k++] = st[u][j++] + add;
  for (i = 0; i < k; i++) {
    if (i < l1)
      st[v][i] = tmp[i];
    else
      st[v].push_back(tmp[i]);
  }
}
long long cal(int v, int h) {
  if (v < 1 || v > n || h < 0) return 0;
  int l = 0, r = st[v].size() - 1;
  while (l < r) {
    int mid = l + r + 1 >> 1;
    if (st[v][mid] > h)
      r = mid - 1;
    else
      l = mid;
  }
  long long rtn = 1LL * (l + 1) * h - sst[v][l];
  return rtn;
}
int main() {
  scanf("%d%d", &n, &q);
  st[1].push_back(0);
  for (int i = 2; i <= n; i++) {
    scanf("%d", &len[i]);
    st[i].push_back(0);
  }
  for (int i = n; i >= 2; i--) Merge(i / 2, i);
  for (int i = 1; i <= n; i++) {
    int l = st[i].size();
    long long sum = 0;
    for (int j = 0; j < l; j++) {
      sum += (long long)st[i][j];
      sst[i].push_back(sum);
    }
  }
  while (q--) {
    int v, h;
    scanf("%d%d", &v, &h);
    int tv = v;
    long long ans = cal(v, h);
    h -= len[v];
    v /= 2;
    for (; v >= 1 && h > 0; v /= 2) {
      ans += h;
      for (int i = 0; i < 2; i++) {
        int u = v * 2 + i;
        if (tv != u) ans += cal(u, h - len[u]);
      }
      tv = v;
      h -= len[v];
    }
    printf("%I64d\n", ans);
  }
  return 0;
}
