#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
long long mul(long long a, long long b) { return (a * b) % mod; }
long long bin_pow(long long a, long long b) {
  long long ans = 1;
  long long tmp = a;
  while (b) {
    if (b & 1) {
      ans = mul(ans, tmp);
    }
    tmp = mul(tmp, tmp);
    b >>= 1;
  }
  return ans;
}
long long inv(long long a) { return bin_pow(a, mod - 2); }
const int maxn = 3e5;
long long factorial[maxn];
long long c(int n, int k) {
  if (k > n) return 0;
  return mul(factorial[n], mul(inv(factorial[n - k]), inv(factorial[k])));
}
long long add(long long a, long long b) { return (a + b) % mod; }
long long sub(long long a, long long b) {
  long long ans = (a - b) % mod;
  if (ans < 0) ans += mod;
  return ans;
}
void solve() {
  factorial[0] = 1;
  for (int i = 1; i < maxn; i++) {
    factorial[i] = mul(factorial[i - 1], i);
  }
  int n;
  cin >> n;
  long long T;
  cin >> T;
  long long sum_t = 0;
  long long sum_c = 1;
  long long old_sum_len = 0;
  long long ans = 0;
  for (int i = 1; i <= n; i++) {
    int ti;
    cin >> ti;
    sum_t += ti;
    sum_c = add(mul(2, sum_c), c(i - 1, old_sum_len + 1));
    old_sum_len++;
    long long exp_sum_len = min((long long)i, T - sum_t);
    if (exp_sum_len < 0) exp_sum_len = -1;
    while (old_sum_len != exp_sum_len) {
      sum_c = sub(sum_c, c(i, old_sum_len));
      old_sum_len--;
    }
    long long tmp = mul(sum_c, inv(bin_pow(2, i)));
    ans = add(ans, tmp);
  }
  cout << ans;
}
int main() {
  solve();
  return 0;
}
