#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
const int N = 9e4 + 4;
int main() {
  int t;
  scanf("%d", &t);
  while (t--) {
    int n, d;
    scanf("%d", &n);
    scanf("%d", &d);
    int ans = 0;
    for (int i = 0; i < n; i++) {
      int val;
      scanf("%d", &val);
      if (i * val <= d) {
        ans += val;
        d -= (i * val);
      } else {
        int here = d / i;
        ans += here;
        d = 0;
      }
    }
    printf("%d\n", ans);
  }
  return 0;
}
