#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 15;
const int mod = 1e9 + 7;
const int inf = 0x3f3f3f3f;
int n;
long long T;
int sump[maxn];
long long t[maxn];
long long pow_mod(long long a, long long b) {
  long long ret = 1;
  while (b) {
    if (b & 1) ret = ret * a % mod;
    a = a * a % mod;
    b >>= 1;
  }
  return ret;
}
long long fac[maxn], inv[maxn];
long long C(int n, int m) {
  if (m > n) return 0;
  return fac[n] * inv[m] % mod * inv[n - m] % mod;
}
int main() {
  fac[0] = 1;
  for (int i = 1; i < maxn; i++) fac[i] = fac[i - 1] * i % mod;
  inv[maxn - 1] = pow_mod(fac[maxn - 1], mod - 2);
  for (int i = maxn - 2; i >= 0; i--) inv[i] = inv[i + 1] * (i + 1) % mod;
  scanf("%d%lld", &n, &T);
  for (int i = 1; i <= n; i++) {
    scanf("%lld", &t[i]);
    t[i] += t[i - 1];
  }
  int last = 1;
  long long lastsum = 0;
  long long ans = 0;
  long long powtwo = 1;
  for (int i = 1; i <= n; i++) {
    int cc = min((long long)i, T - t[i]);
    powtwo = powtwo * 2 % mod;
    if (cc < 0) break;
    if (cc == 0) {
      ans = (ans + pow_mod(powtwo, mod - 2)) % mod;
      continue;
    }
    lastsum = (lastsum - (i - 1) + mod) % mod;
    lastsum = lastsum * 2 % mod;
    if (last > 1) lastsum = (lastsum - C(i - 1, last) + mod) % mod;
    lastsum = (lastsum + i) % mod;
    if (last > 1) lastsum = (lastsum + (i - 1)) % mod;
    while (last > cc) {
      lastsum = (lastsum - C(i, last) + mod) % mod;
      last--;
    }
    while (last < cc) {
      lastsum = (lastsum + C(i, last + 1)) % mod;
      last++;
    }
    ans = (ans + (lastsum + 1) % mod * pow_mod(powtwo, mod - 2) % mod) % mod;
  }
  printf("%lld\n", ans);
  return 0;
}
