#include <bits/stdc++.h>
using namespace std;
const int NMAX = 1000005;
int n, m, u;
long long t;
vector<long long> a[NMAX];
vector<long long> sum[NMAX];
vector<long long> hp(NMAX);
long long cal(int u, long long v) {
  int i = lower_bound(a[u].begin(), a[u].end(), v) - a[u].begin();
  if (i - 1 >= 0) {
    return i * v - sum[u][i - 1];
  }
  return 0;
}
int main() {
  std::ios_base::sync_with_stdio(false);
  cin >> n >> m;
  for (int i = 2; i <= n; i++) {
    cin >> t;
    hp[i] = t;
    for (int j = i >> 1; j > 0; j >>= 1) {
      a[j].push_back(t);
      t += hp[j];
    }
  }
  for (int i = 1; i <= n; i++) {
    a[i].push_back(0);
    sort(a[i].begin(), a[i].end());
    sum[i] = a[i];
    for (int j = 1; j < a[i].size(); j++) {
      sum[i][j] += sum[i][j - 1];
    }
  }
  long long ans = 0;
  for (int i = 0; i < m; i++) {
    cin >> u >> t;
    ans = cal(u, t);
    for (; u > 1; u >>= 1) {
      t -= hp[u];
      if (t < 0) {
        break;
      }
      ans += t + cal(u ^ 1, t - hp[u ^ 1]);
    }
    cout << ans << '\n';
  }
  return 0;
}
