#include <bits/stdc++.h>
using namespace std;
const int M = 200005;
const int MOD = 1e9 + 7;
long long read() {
  long long num = 0, flag = 1;
  char c;
  while ((c = getchar()) < '0' || c > '9')
    if (c == '-') flag = -1;
  while (c >= '0' && c <= '9')
    num = (num << 3) + (num << 1) + (c ^ 48), c = getchar();
  return num * flag;
}
long long n, m, s, p, ans, a[M], fac[M], inv[M], pw[M];
void init(long long n) {
  fac[0] = fac[1] = inv[0] = inv[1] = pw[0] = 1;
  for (long long i = 2; i <= n; i++)
    inv[i] = (MOD - MOD / i) * inv[MOD % i] % MOD;
  for (long long i = 2; i <= n; i++) inv[i] = inv[i] * inv[i - 1] % MOD;
  for (long long i = 2; i <= n; i++) fac[i] = fac[i - 1] * i % MOD;
  for (long long i = 1; i <= n; i++) pw[i] = pw[i - 1] * 500000004 % MOD;
}
long long C(long long n, long long m) {
  if (n < m) return 0;
  return fac[n] * inv[m] % MOD * inv[n - m] % MOD;
}
signed main() {
  init(200000);
  n = read();
  m = read();
  for (long long i = 1; i <= n; i++) a[i] = a[i - 1] + read();
  s = 1;
  p = min(m, n);
  for (long long i = 1; i <= n; i++) {
    if (m - a[i] < 0) break;
    s = (2 * s - C(i - 1, p)) % MOD;
    long long np = min(m - a[i], n);
    for (long long j = p; j > np; j--) s = (s - C(i, j)) % MOD;
    p = np;
    ans = (ans + pw[i] * s) % MOD;
  }
  printf("%lld\n", (ans + MOD) % MOD);
}
