#include <bits/stdc++.h>
using namespace std;
template <typename T>
inline bool chkmin(T &a, const T &b) {
  return a > b ? a = b, 1 : 0;
}
template <typename T>
inline bool chkmax(T &a, const T &b) {
  return a < b ? a = b, 1 : 0;
}
const int INF = 0x3f3f3f3f;
template <class T>
inline bool RD(T &ret) {
  char c;
  int sgn;
  if (c = getchar(), c == EOF) return 0;
  while (c != '-' && (c < '0' || c > '9')) c = getchar();
  sgn = (c == '-') ? -1 : 1, ret = (c == '-') ? 0 : (c - '0');
  while (c = getchar(), c >= '0' && c <= '9') ret = ret * 10 + (c - '0');
  ret *= sgn;
  return 1;
}
template <class T>
inline void PT(T x) {
  if (x < 0) putchar('-'), x = -x;
  if (x > 9) PT(x / 10);
  putchar(x % 10 + '0');
}
const int N = 1e6 + 10;
vector<pair<int, long long> > G[N];
long long dis[N];
int main() {
  int n, Q;
  cin >> n >> Q;
  for (int u = 1; u <= n; u++) {
    int w = 0;
    if (u != 1) scanf("%d", &w);
    dis[u] = dis[u / 2] + w;
    int v = u;
    while (v) {
      G[v].push_back(pair<int, long long>(dis[u] - dis[v], 0));
      v = v / 2;
    }
  }
  for (int u = 1; u <= n; u++) {
    sort((G[u]).begin(), (G[u]).end());
    for (int i = 0; i < (int((G[u]).size())); i++) {
      G[u][i].second = G[u][i].first;
      if (i != 0) G[u][i].second += G[u][i - 1].second;
    }
  }
  long long ans = 0, lev;
  while (Q--) {
    int u;
    long long H;
    ans = 0;
    scanf("%d %lld", &u, &H);
    int v = u, lst = -1, o = u;
    while (v) {
      if (lst != -1) o = lst ^ 1;
      lev = H - (dis[u] - dis[v] + dis[o] - dis[v]);
      int p = lower_bound((G[o]).begin(), (G[o]).end(),
                          pair<int, long long>(lev, 1LL << 60)) -
              G[o].begin();
      if (p) ans += lev * p - G[o][p - 1].second;
      lst = v;
      v = v / 2;
      if (v != 0 && dis[u] - dis[v] <= H) ans += H - (dis[u] - dis[v]);
    }
    printf("%lld\n", ans);
  }
}
