#include <bits/stdc++.h>
using namespace std;
const int MAXN = 300001;
long long t;
int n;
long long s[MAXN];
int fac[MAXN], revfac[MAXN], pow2[MAXN];
int mod = (int)(1e9) + 7;
int ksm(int x, int y) {
  int sum = 1;
  for (; y; y >>= 1) {
    if (y & 1) sum = 1LL * sum * x % mod;
    x = 1LL * x * x % mod;
  }
  return sum;
}
int C(int nn, int kk) {
  return 1LL * fac[nn] * revfac[kk] % mod * revfac[nn - kk] % mod;
}
int main() {
  scanf("%d%I64d", &n, &t);
  int bound = n;
  s[0] = 0;
  for (int i = 1; i <= n; ++i) {
    scanf("%I64d", &s[i]);
    s[i] += s[i - 1];
    if (s[i] > t and bound == n) bound = i - 1;
  }
  fac[0] = revfac[0] = pow2[0] = 1;
  for (int i = 1; i <= n; ++i) {
    fac[i] = 1LL * i * fac[i - 1] % mod;
    pow2[i] = 2LL * pow2[i - 1] % mod;
  }
  for (int i = 0; i <= n; ++i) {
    revfac[i] = ksm(fac[i], mod - 2);
    pow2[i] = ksm(pow2[i], mod - 2);
  }
  int delta = 0;
  int ans = 0;
  while (bound >= delta) {
    if (bound == n)
      delta = 0;
    else if (t - s[bound + 1] < 0)
      delta = 0;
    else {
      delta = t - s[bound + 1];
      if (delta > bound) break;
      ans += 1LL * pow2[bound + 1] * C(bound, delta) % mod * bound % mod;
      ans %= mod;
      ++delta;
    }
    while (delta <= t - s[bound] and delta <= bound) {
      ans += 1LL * pow2[bound] * C(bound, delta) % mod * bound % mod;
      ans %= mod;
      ++delta;
    }
    --bound;
    delta = 0;
  }
  printf("%d", ans);
  return 0;
}
