#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
const int maxn = 2e5 + 10;
long long fac[maxn], ifac[maxn], p[maxn], ip[maxn];
long long t[maxn];
int N;
long long T;
long long qpow(long long x, long long n) {
  if (n <= 0) return 1;
  long long ret = qpow(x, n >> 1);
  ret = ret * ret % mod;
  if (n & 1) ret = ret * x % mod;
  return ret;
}
long long C(long long n, long long r) {
  if (r > n || n < 0 || r < 0) return 0;
  return fac[n] * (ifac[r] * ifac[n - r] % mod) % mod;
}
void init() {
  fac[0] = p[0] = 1;
  ifac[0] = qpow(fac[0], mod - 2);
  ip[0] = qpow(p[0], mod - 2);
  for (int i = 1; i < maxn; ++i) {
    fac[i] = fac[i - 1] * i % mod;
    p[i] = p[i - 1] * 2 % mod;
    ifac[i] = qpow(fac[i], mod - 2);
    ip[i] = qpow(p[i], mod - 2);
  }
}
int main() {
  init();
  scanf("%d %lld", &N, &T);
  for (int i = 1; i <= N; ++i) {
    scanf("%lld", &t[i]);
  }
  long long sum = 0, ret = 0, prefix = 0;
  int pre = -1;
  for (int i = 1; i <= N; ++i) {
    sum += t[i];
    if (sum > T) break;
    if (sum + i <= T) {
      ret = (ret + 1) % mod;
      continue;
    }
    int K = min((long long)i, T - sum);
    if (prefix == 0) {
      for (int j = 0; j <= K; ++j) {
        prefix = (prefix + C(i, j)) % mod;
      }
      pre = K;
      ret = (ret + prefix * ip[i] % mod) % mod;
    } else {
      prefix = prefix * 2 % mod;
      prefix = (prefix - C(i - 1, pre) + mod) % mod;
      while (pre > K) {
        prefix = (prefix - C(i, pre) + mod) % mod;
        --pre;
      }
      ret = (ret + prefix * ip[i] % mod) % mod;
    }
  }
  printf("%lld\n", ret);
}
