#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e6 + 10;
long long n, q, ans[MAXN], go[MAXN];
long long suml[MAXN], sumr[MAXN];
vector<pair<int, pair<int, int>>> qu[MAXN];
vector<long long> dfs(int v) {
  vector<long long> l, r;
  suml[0] = 0;
  sumr[0] = 0;
  if ((v * 2) <= n) l = dfs(v * 2);
  if ((v * 2 + 1) <= n) r = dfs(v * 2 + 1);
  for (int i = 0; i < l.size(); i++) {
    l[i] += go[v * 2];
    suml[i + 1] = suml[i] + l[i];
  }
  for (int i = 0; i < r.size(); i++) {
    r[i] += go[v * 2 + 1];
    sumr[i + 1] = sumr[i] + r[i];
  }
  for (auto i : qu[v]) {
    int ind = i.first;
    long long le = i.second.first;
    int dir = i.second.second;
    if (dir != 0) {
      int good = upper_bound(l.begin(), l.end(), le) - l.begin();
      ans[ind] += good * le - suml[good];
    }
    if (dir != 1) {
      int good = upper_bound(r.begin(), r.end(), le) - r.begin();
      ans[ind] += good * le - sumr[good];
    }
    if (le > 0) ans[ind] += le;
  }
  vector<long long> me;
  me.push_back(0);
  int pl = 0, pr = 0;
  int sl = l.size(), sr = r.size();
  while (pl != sl && pr != sr) {
    if (l[pl] < r[pr])
      me.push_back(l[pl++]);
    else
      me.push_back(r[pr++]);
  }
  while (pl != sl) me.push_back(l[pl++]);
  while (pr != sr) me.push_back(r[pr++]);
  return me;
}
int main() {
  ios::sync_with_stdio(0);
  cin >> n >> q;
  for (int i = 1; i < n; i++) {
    cin >> go[i + 1];
  }
  for (int i = 1; i <= q; i++) {
    int u, v;
    cin >> u >> v;
    qu[u].push_back({i, {v, 2}});
    while (u > 1) {
      v -= go[u];
      qu[u / 2].push_back({i, {v, u & 1}});
      u /= 2;
    }
  }
  dfs(1);
  for (int i = 1; i <= q; i++) {
    cout << ans[i] << endl;
  }
  cin >> q;
  return 0;
}
