#include <bits/stdc++.h>
using namespace std;
long long arr[200005];
long long n, T;
long long inv[200005];
long long fac[200005];
long long power(long long a, long long b) {
  long long ans = 1, c = a;
  while (b > 0) {
    if (b & 1) {
      ans *= c;
      ans %= 1000000007;
    }
    c = (c * c) % 1000000007;
    b >>= 1;
  }
  return ans;
}
long long com(long long nn, long long k) {
  return (((fac[nn] * power(fac[k], 1000000007 - 2)) % 1000000007) *
          power(fac[nn - k], 1000000007 - 2)) %
         1000000007;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  fac[0] = 1;
  inv[0] = 1;
  for (int i = 1; i < 200005; i++) {
    inv[i] = (inv[i - 1] * 2) % 1000000007;
    fac[i] = fac[i - 1] * i;
    fac[i] %= 1000000007;
  }
  cin >> n >> T;
  for (int i = 1; i <= n; i++) {
    cin >> arr[i];
  }
  int L = 0, R = 0;
  long long sum = 0;
  long long per = 1;
  long long pre = 0;
  long long cur = 0;
  long long ans = 0;
  for (long long i = 1; i <= n; i++) {
    sum += arr[i];
    if (sum > T) break;
    cur = min(i, T - sum);
    per = (per << 1) % 1000000007;
    per -= com(i - 1, 0) - 1000000007;
    per %= 1000000007;
    per -= com(i - 1, pre) - 1000000007;
    per %= 1000000007;
    per += com(i, 0);
    per %= 1000000007;
    per += com(i, pre + 1);
    per %= 1000000007;
    for (int j = pre + 1; j > cur; j--) {
      per -= com(i, j) - 1000000007;
      per %= 1000000007;
    }
    ans += (power(inv[i], 1000000007 - 2) * per) % 1000000007;
    ans %= 1000000007;
    pre = cur;
  }
  cout << ans << endl;
}
