#include <bits/stdc++.h>
long long int const MOD = 1000000007;
long long int const N = 1000005;
long long int const LN = 20;
long long int const inf = 8e18;
using namespace std;
long long int n, m, a[N];
long long int fact[N];
long long int ifact[N];
long long int bexpo(long long int x, long long int n, long long int m) {
  long long int r = 1;
  x = x % m;
  while (n > 0) {
    if (n % 2) {
      r = (r * x) % m;
    }
    x = (x * x) % m;
    n = n / 2;
  }
  return r;
}
long long int ncr(long long int n, long long int r) {
  if (r > n) {
    return 0;
  }
  long long int ans = fact[n];
  ans = (ans * ifact[r]) % MOD;
  ans = (ans * ifact[n - r]) % MOD;
  return ans;
}
void pre() {
  fact[0] = 1;
  ifact[0] = 1;
  for (long long int i = 1; i < N; i++) {
    fact[i] = (fact[i - 1] * i) % MOD;
  }
  ifact[N - 1] = bexpo(fact[N - 1], MOD - 2, MOD);
  for (long long int i = N - 2; i > 0; i--) {
    ifact[i] = (ifact[i + 1] * (i + 1)) % MOD;
  }
}
long long int p2[N];
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  p2[0] = 1;
  for (long long int i = 1; i < N; i++) {
    p2[i] = 2 * p2[i - 1] % MOD;
  }
  pre();
  long long int n, t;
  cin >> n >> t;
  for (long long int i = 1; i <= n; i++) {
    cin >> a[i];
  }
  long long int sm = 0;
  long long int ans = 0;
  long long int prev = 1;
  long long int idx = 0;
  for (long long int i = 1; i <= n; i++) {
    sm += a[i];
    long long int temp = t - sm;
    if (temp < 0) {
      break;
    }
    temp = min(i, temp);
    long long int inv2 = bexpo(p2[i], MOD - 2, MOD);
    long long int ok = 2 * prev;
    if (ok < 0) {
      ok += MOD;
    }
    ok -= ncr(i - 1, idx);
    ok %= MOD;
    if (ok < 0) {
      ok += MOD;
    }
    ok %= MOD;
    while (idx > temp) {
      ok -= ncr(i, idx);
      idx--;
      ok %= MOD;
      if (ok < 0) {
        ok += MOD;
      }
    }
    while (idx < temp) {
      ok += ncr(i, idx + 1);
      idx++;
      ok %= MOD;
    }
    prev = ok;
    idx = temp;
    ok *= inv2;
    ok %= MOD;
    ans += ok;
    ans %= MOD;
  }
  cout << ans;
  return 0;
}
