#include <bits/stdc++.h>
using namespace std;
int main() {
  long long t;
  cin >> t;
label:
  while (t--) {
    long long n, d;
    cin >> n >> d;
    long long arr[n];
    for (long long i = 0; i < n; i++) cin >> arr[i];
    long long ans = 0;
    for (long long i = 1; i <= n - 1; i++) {
      long long x = min(arr[i], d / i);
      ans += x;
      d -= x * i;
    }
    cout << ans + arr[0] << endl;
  }
}
