#include <bits/stdc++.h>
using namespace std;
const long long INF = 0x3f3f3f3f;
const int N = 2e5 + 10;
const long long mod = 1e9 + 7;
const bool debug = false;
int F[N], Finv[N], inv[N];
void init() {
  inv[1] = 1, F[0] = Finv[0] = 1;
  for (int i = 2; i < N; i++)
    inv[i] = (mod - mod / i) * 1ll * inv[mod % i] % mod;
  for (int i = 1; i < N; i++) {
    F[i] = F[i - 1] * 1ll * i % mod;
    Finv[i] = Finv[i - 1] * 1ll * inv[i] % mod;
  }
}
int comb(int n, int m) {
  if (m < 0 || m > n) return 0;
  return F[n] * 1ll * Finv[n - m] % mod * Finv[m] % mod;
}
int main() {
  init();
  int n;
  long long T;
  scanf("%d%lld", &n, &T);
  long long pre = 1, r = 0, ans = 0, gg = 1;
  for (int i = 1, x; i <= n; ++i) {
    scanf("%d", &x);
    T -= x;
    if (T < 0) break;
    pre = (pre * 2 - comb(i - 1, r) + mod) % mod;
    while (r < min(i * 1ll, T)) {
      pre += comb(i, ++r);
    }
    while (r > min(i * 1ll, T)) {
      pre -= comb(i, r--);
    }
    pre %= mod;
    if (pre < 0) pre += mod;
    gg = gg * (mod + 1) / 2 % mod;
    ans = (ans + pre * gg) % mod;
  }
  printf("%lld\n", ans);
  return 0;
}
