#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
const int maxn = 2e5 + 10;
long long t[maxn];
long long T;
int n;
int mul(int a, int b) {
  long long t = 1ll * a * b;
  return t - t / mod * mod;
}
int add(int a, int b) {
  a += b;
  if (a >= mod) return a - mod;
  return a;
}
int qp(int a, int b) {
  int ans = 1;
  while (b) {
    if (b & 1) ans = mul(ans, a);
    a = mul(a, a);
    b >>= 1;
  }
  return ans;
}
int fac[maxn], facinv[maxn], pw[maxn], powinv[maxn];
int C(int a, int b) {
  if (a < b) return 0;
  return mul(fac[a], mul(facinv[b], facinv[a - b]));
}
int main() {
  fac[0] = pw[0] = 1;
  for (int i = 1; i < maxn; ++i) fac[i] = mul(fac[i - 1], i);
  for (int i = 1; i < maxn; ++i) pw[i] = mul(pw[i - 1], 2);
  facinv[maxn - 1] = qp(fac[maxn - 1], mod - 2);
  powinv[maxn - 1] = qp(pw[maxn - 1], mod - 2);
  for (int i = maxn - 2; i >= 0; --i) facinv[i] = mul(facinv[i + 1], i + 1);
  for (int i = maxn - 2; i >= 0; --i) powinv[i] = mul(powinv[i + 1], 2);
  ios::sync_with_stdio(false);
  cin >> n >> T;
  for (int i = 1; i <= n; ++i) cin >> t[i];
  for (int i = 1; i <= n; ++i) t[i] += t[i - 1];
  int ans = 0, d;
  if (t[1] > T) {
    cout << 0 << endl;
    return 0;
  }
  for (int b = 0, k; b <= n; ++b) {
    k = upper_bound(t, t + n + 1, T - b) - t - 1;
    if (k < 0) continue;
    ans = add(ans, mul(mul(C(k, b), powinv[k]), k));
    if (k != n && b != 0 && T - (t[k] + b - 1) >= t[k + 1] - t[k])
      ans = add(ans, mul(mul(C(k, b - 1), powinv[k + 1]), k));
  }
  cout << ans << endl;
  return 0;
}
