#include <bits/stdc++.h>
const int N = 1000005;
int n, t;
inline void read(int &x) {
  register char ch = 0;
  register bool w = 0;
  for (x = 0; !std::isdigit(ch); w |= ch == '-', ch = getchar())
    ;
  for (; std::isdigit(ch); x = x * 10 + ch - '0', ch = getchar())
    ;
  (w) && (x = -x);
  return;
}
int ai[N];
void solve() {
  read(n);
  int ans = 0;
  int d;
  read(d);
  bool flag = 0;
  for (int i = 1; i <= n; ++i) {
    read(ai[i]);
    if (i == 1) continue;
    if (d <= 0) {
      continue;
    }
    if (d >= ai[i] * (i - 1))
      ans += ai[i], d -= ai[i] * (i - 1);
    else {
      ans += d / (i - 1);
      d = 0;
    }
  }
  ans += ai[1];
  printf("%d\n", ans);
}
int main() {
  read(t);
  while (t--) {
    solve();
  }
  return 0;
}
