#include <bits/stdc++.h>
using namespace std;
vector<long long> invi(long long n) {
  long long x;
  vector<long long> a;
  for (long long i = 0; i < n; i++) {
    cin >> x;
    a.push_back(x);
  }
  return a;
}
vector<bool> prime;
void checkPrime(long long n) {
  for (long long i = 0; i < n + 1; i++) {
    prime.push_back(true);
  }
  prime[0] = false;
  prime[1] = false;
  for (long long p = 2; p * p <= n; p++) {
    if (prime[p] == true) {
      for (long long i = p * p; i <= n; i += p) prime[i] = false;
    }
  }
}
void solve();
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int t = 1;
  cin >> t;
  while (t--) {
    solve();
  }
}
void solve() {
  long long n, d;
  cin >> n >> d;
  vector<long long> a = invi(n);
  long long cnt = 1;
  for (long long i = 1; 1 < n ? i < n : i > n; 1 < n ? i += 1 : i -= 1) {
    long long mov = d / cnt;
    if (mov < a[i]) {
      a[0] += mov;
      break;
    } else {
      a[0] += a[i];
      d -= (a[i] * cnt);
    }
    cnt++;
  }
  cout << a[0] << "\n";
}
