#include <bits/stdc++.h>
long long mod = 1e18;
using namespace std;
long long ceiling(long long a, long long b) {
  if (a % b == 0)
    return a / b;
  else
    return a / b + 1;
}
long long power(long long a, long long b) {
  if (b == 0)
    return 1;
  else if (b % 2 == 1) {
    long long k = power(a, b / 2) % mod;
    return (((a * k) % mod) * k) % mod;
  } else {
    long long k = power(a, b / 2) % mod;
    return (k * k) % mod;
  }
}
long long gcd(long long a, long long b) {
  if (a > b) swap(a, b);
  if (a == 0) return b;
  return gcd(b % a, a);
}
pair<long long, long long> overlap(pair<long long, long long> a,
                                   pair<long long, long long> b) {
  return make_pair(max(a.first, b.first), min(a.second, b.second));
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long t;
  cin >> t;
  while (t--) {
    long long n, d, i, j, ans = 0, sum = 0;
    cin >> n >> d;
    vector<long long> a(n);
    for (i = 0; i < n; i++) {
      cin >> a[i];
      if (i == 0)
        ans += a[i];
      else {
        if (sum + a[i] * i <= d) {
          sum += a[i] * i;
          ans += a[i];
        } else {
          ans += ((d - sum) / i);
          sum = d;
        }
      }
    }
    cout << ans << endl;
  }
}
