#include <bits/stdc++.h>
const long long N = 200002, M = 1e9 + 7;
long long g[N], f[N], n, i, now, ans, j, x, p, T;
long long pw(long long x, long long y) {
  long long z = 1;
  for (; y; y >>= 1, x = x * x % M)
    if (y & 1) z = z * x % M;
  return z;
}
long long C(long long n, long long m) {
  return n < m ? 0 : f[n] * g[m] % M * g[n - m] % M;
}
signed main() {
  scanf("%lld%lld", &n, &T);
  f[0] = 1;
  for (i = 1; i < N; i++) f[i] = f[i - 1] * i % M;
  g[N - 1] = pw(f[N - 1], M - 2);
  for (i = N - 2; ~i; i--) g[i] = g[i + 1] * (i + 1) % M;
  for (i = now = 1; i <= n; now = now * 2 - C(i, j), i++) {
    scanf("%lld", &x), p = std::min(T -= x, i);
    if (p < 0) break;
    for (; j < p; j++) now += C(i, j + 1);
    for (; j > p; j--) now -= C(i, j);
    ans += (now %= M) * pw(2, n - i) % M;
  }
  printf("%lld", (ans % M * pw(2, n * (M - 2)) % M + M) % M);
}
