#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9 + 7;
inline int add(int x, int y) {
  int res = x + y;
  while (res >= MOD) res -= MOD;
  return res;
}
inline int mul(int x, int y) { return (1LL * x * y) % MOD; }
int modpow(int x, int p) {
  int res = 1;
  while (p) {
    if (p & 1) res = mul(res, x);
    x = mul(x, x);
    p /= 2;
  }
  return res;
}
inline int invert(int x) { return modpow(x, MOD - 2); }
const int N = 2e5 + 5;
int fac[N], inv[N];
void init(int n) {
  fac[0] = inv[0] = 1;
  for (int i = 1; i < n; ++i) {
    fac[i] = mul(fac[i - 1], i);
    inv[i] = invert(fac[i]);
  }
}
int comb(int n, int k) { return mul(fac[n], mul(inv[k], inv[n - k])); }
int main() {
  cin.tie(0);
  cout.tie(0);
  ios_base::sync_with_stdio(0);
  init(N);
  int n;
  long long T;
  cin >> n >> T;
  vector<int> v(n + 1);
  for (int i = 0; i < n; ++i) cin >> v[i];
  v[n] = T + 1;
  long long sum = 0, ans = 0;
  bool hit = false;
  int inv = invert(2), dem = 1, mmax = 0;
  for (int i = 0; i < n + 1; ++i) {
    dem = mul(dem, inv);
    sum += v[i];
    long long mx = sum + (i + 1);
    if (mx > T) {
      hit = true;
      long long lim = max(T - sum, -1LL);
      int p = 0;
      for (int j = mmax; j > lim; --j) {
        p = add(p, mul(comb(i + 1, j), dem));
      }
      p = add(p, mul(comb(i, mmax), dem));
      ans = add(ans, mul(i, p));
      mmax = lim;
    }
    if (!hit) mmax = i + 1;
  }
  cout << ans << '\n';
}
