#include <bits/stdc++.h>
using namespace std;
long long T, n, d, sum, x;
int main() {
  cin >> T;
  for (int i = 1; i <= T; i++) {
    cin >> n >> d >> sum;
    for (int i = 2; i <= n; i++) {
      cin >> x;
      while (x > 0 && d >= (i - 1)) {
        x--;
        sum++;
        d = d - i + 1;
      }
    }
    cout << sum << endl;
  }
  return 0;
}
