#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
void Add(long long &a, long long b) {
  a += b;
  if (a >= mod) a -= mod;
  if (a < 0) a += mod;
}
int n;
long long T, A[200005];
long long fac[200005], inv[200005];
long long Pow(long long x, long long b) {
  long long res = 1;
  while (b) {
    if (b & 1) res = res * x % mod;
    x = x * x % mod;
    b >>= 1;
  }
  return res;
}
void init() {
  fac[0] = 1;
  for (int i = 1; i <= n; i++) fac[i] = fac[i - 1] * i % mod;
  inv[n] = Pow(fac[n], mod - 2);
  for (int i = n - 1; i >= 0; i--) inv[i] = inv[i + 1] * (i + 1) % mod;
}
int la, lb;
long long ans, ANS;
long long C(int a, int b) {
  if (a < b || b < 0) return 0;
  return fac[a] * inv[b] % mod * inv[a - b] % mod;
}
void move(int b) {
  while (lb < b) Add(ans, C(la, ++lb));
  while (lb > b) Add(ans, -C(la, lb--));
}
void Solve() {
  ans = 1, la = lb = 0;
  long long inv2 = Pow(2, mod - 2), div = inv2;
  for (long long i = 1, ts = 0; i <= n; i++, div = div * inv2 % mod) {
    ts += A[i];
    int b = min(i, T - ts);
    if (b < 0) break;
    ans = (ans * 2 - C(la, lb)) % mod;
    la = i;
    move(b);
    Add(ANS, ans * div % mod);
  }
}
int main() {
  cin >> n >> T;
  for (int i = 1; i <= n; i++) cin >> A[i];
  init();
  Solve();
  ANS = (ANS % mod + mod) % mod;
  cout << ANS << endl;
  return 0;
}
