#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 5;
int fact[N], factinv[N], inv[N];
template <typename T, typename T1>
T nCr(T n, T1 r) {
  if (r > n) return 0;
  int ans = (int)((1ll * factinv[r] * factinv[n - r]) % 1000000007);
  ans = (int)((1ll * ans * fact[n]) % 1000000007);
  return ans;
}
template <typename T>
T mod(T x) {
  x %= 1000000007;
  if (x < 0) x += 1000000007;
  return x;
}
template <typename T>
T modinv(T x) {
  x = mod(x);
  if (x == 1) return 1;
  return (
      (int)mod(1ll * (-1000000007 / x) * (inv[1000000007 % x] % 1000000007)));
}
template <typename T, typename T1>
T expo(T a, T1 b) {
  if (b == 0) return 1;
  if (b & 1) return (int)(1ll * a * expo(a, b - 1) % 1000000007);
  a = expo(a, b / 2);
  return (int)(1ll * a * a % 1000000007);
}
int32_t main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  int i, n, k, t;
  int64_t T, S = 0, ans = 0, mi = 1, prvmi = 0, j, sigma = 1;
  cin >> n >> T;
  fact[0] = factinv[0] = 1;
  for (i = 1; i < N; i++) {
    fact[i] = (int)((1ll * fact[i - 1] * i) % 1000000007);
    inv[i] = modinv(i);
    factinv[i] = (int)((1LL * factinv[i - 1] * inv[i]) % 1000000007);
  }
  for (i = 1; i <= n; i++, mi++) {
    cin >> t;
    S += t;
    if (S > T) break;
    mi = (mi < T - S ? mi : T - S);
    if (mi > prvmi)
      for (j = mi; j > prvmi; j--) sigma = mod(sigma + nCr(i, j));
    else
      for (j = prvmi; j > mi; j--) sigma = mod(sigma - nCr(i, j));
    int modinv = expo(2, i);
    modinv = modinv < N ? inv[modinv] : expo(modinv, 1000000007 - 2);
    int64_t Pi = mod(sigma * modinv);
    ans = mod(ans + Pi);
    sigma = mod(sigma * 2);
    sigma = mod(sigma + nCr(i, mi + 1));
    sigma = mod(sigma - nCr(i + 1, mi + 1));
    prvmi = mi;
  }
  cout << ans;
  return 0;
}
