#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 5;
const int ha = 1e9 + 7;
long long A[N], f[N], g[N], h[N], B = 440;
struct pp {
  int l, r;
} s[N];
int tot;
bool cmp(pp w, pp v) {
  if (w.l / B == v.l / B) return w.r < v.r;
  return w.l < v.l;
}
long long inv(long long a) {
  long long r = 1, b = ha - 2;
  while (b) {
    if (b & 1) r = r * a % ha;
    a = a * a % ha;
    b >>= 1;
  }
  return r;
}
int C(int n, int m) {
  if (n < m) return 0;
  return (long long)f[n] * g[n - m] % ha * g[m] % ha;
}
int main() {
  f[0] = g[0] = h[0] = 1;
  for (int i = 1; i < N; ++i) {
    f[i] = f[i - 1] * i % ha;
    g[i] = inv(f[i]);
    h[i] = h[i - 1] * 2 % ha;
  }
  long long n, T;
  cin >> n >> T;
  long long IP2 = inv(h[n]);
  long long ans = 0;
  for (int i = 1; i <= n; ++i) {
    cin >> A[i];
    A[i] += A[i - 1];
  }
  for (int i = 0, r = n; i <= n && r >= i;) {
    while (A[r] + i > T && r >= i) --r, IP2 = IP2 * 2 % ha;
    if (i > 0 && r >= i - 1) ans += C(r, i - 1) * IP2 % ha * g[2] % ha * r % ha;
    while (A[r] + i <= T && r >= i) ans += C(r, i++) * IP2 % ha * r % ha;
  }
  cout << ans % ha << endl;
  return 0;
}
