#include <bits/stdc++.h>
using namespace std;
const int maxn = 300005, maxm = 515;
const double pi = acos(-1.0);
const long long mod = 1000000007;
long long ksm(long long a, long long k) {
  long long r = 1;
  while (k > 0) {
    if (k & 1) r = r * a % mod;
    a = a * a % mod;
    k >>= 1;
  }
  return r;
}
int n;
long long t;
int a[maxn];
long long jci[maxn] = {1, 0}, jc[maxn] = {1, 0}, iv2;
int main() {
  int i, j, k;
  iv2 = ksm(2, mod - 2);
  for (i = 1; i < maxn; i++) {
    jc[i] = jc[i - 1] * i % mod;
    jci[i] = ksm(jc[i], mod - 2);
  }
  scanf("%d %I64d", &n, &t);
  for (i = 0; i < n; i++) scanf("%d", a + i);
  long long ans = 0, ct = t, ctt = t, bw;
  for (i = 0; i < n; i++) {
    ct -= a[i];
    if (ct - i - 1 >= 0) {
      ans++;
      ctt = ct;
      continue;
    }
    if (ct < 0) break;
    if (ctt >= i) {
      bw = 0;
      for (j = 0; j <= ct; j++)
        bw += jc[i + 1] * jci[j] % mod * jci[i + 1 - j] % mod, bw %= mod;
    } else {
      bw = bw * 2 % mod + mod - jc[i] * jci[ctt] % mod * jci[i - ctt] % mod;
      bw %= mod;
      for (j = ctt; j > ct; j--) {
        bw += mod - jc[i + 1] * jci[j] % mod * jci[i + 1 - j] % mod;
        bw %= mod;
      }
    }
    ans += bw * ksm(iv2, i + 1) % mod;
    ans %= mod;
    ctt = ct;
  }
  printf("%I64d\n", ans);
  return 0;
}
