#include <bits/stdc++.h>
using namespace std;
int inv[200001], fact[200001], inv_fact[200001];
void precomp() {
  inv[1] = 1;
  for (long long ctr1 = 2; ctr1 < 200001; ++ctr1)
    inv[ctr1] = (1000000007 -
                 (1000000007 / ctr1) * inv[1000000007 % ctr1] % 1000000007) %
                1000000007;
  fact[0] = inv_fact[0] = 1;
  for (long long ctr1 = 1; ctr1 < 200001; ++ctr1) {
    fact[ctr1] = fact[ctr1 - 1] * ctr1 % 1000000007;
    inv_fact[ctr1] = 1LL * inv_fact[ctr1 - 1] * inv[ctr1] % 1000000007;
  }
}
int comb(int n, int k) {
  if (k < 0 || k > n) return 0;
  return (1LL * fact[n] * inv_fact[k] % 1000000007) * inv_fact[n - k] %
         1000000007;
}
int pn = 0, pk = 0;
long long psum = 1;
int prefix_sum(int n, int k) {
  while (pn < n) psum = (psum * 2 + comb(pn++, (pk++) + 1)) % 1000000007;
  while (pk > k) psum = (psum - comb(pn, pk--) + 1000000007) % 1000000007;
  return psum;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  precomp();
  int n, a;
  long long t, tot = 0;
  cin >> n >> t;
  long long rezp = 0, rezq = 1;
  for (long long ctr1 = 0; ctr1 < n; ++ctr1) {
    cin >> a;
    tot += a;
    rezp = (rezp * 2) % 1000000007;
    rezq = (rezq * inv[2]) % 1000000007;
    rezp = (rezp + prefix_sum(ctr1 + 1, min(ctr1 + 1, max(t - tot, -1LL)))) %
           1000000007;
  }
  cout << (rezp * rezq) % 1000000007 << '\n';
  return 0;
}
