#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int t, n, d, c;
  long long int count;
  cin >> t;
  while (t--) {
    count = 0;
    c = 1;
    cin >> n;
    cin >> d;
    int a[n];
    for (int i = 0; i < n; i++) cin >> a[i];
    while (d != 0) {
      if (c == n) break;
      if ((c * a[c]) > d) {
        count += d / c;
        d = 0;
      } else {
        count += a[c];
        d -= c * a[c];
        c++;
      }
    }
    count += a[0];
    cout << count << "\n";
  }
  return 0;
}
