#include <bits/stdc++.h>
using namespace std;
const int M = 2e5 + 5, P = 1e9 + 7;
int n;
long long T;
int a[M];
long long ans;
long long Pow[M], inv[M];
long long C(int n, int m) { return Pow[n] * inv[m] % P * inv[n - m] % P; }
int main() {
  scanf("%d%lld", &n, &T);
  inv[0] = inv[1] = Pow[0] = Pow[1] = 1;
  for (int i = 2; i <= n + 1; i++) inv[i] = (P - P / i) * inv[P % i] % P;
  for (int i = 2; i <= n + 1; i++) inv[i] = inv[i - 1] * inv[i] % P;
  for (int i = 2; i <= n + 1; i++) Pow[i] = Pow[i - 1] * i % P;
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
  long long Inv = inv[2], sum = 0, res = 1, ans = 0;
  for (int i = 1, pp = 0; i <= n; i++, Inv = Inv * inv[2] % P) {
    sum += a[i];
    int p = min(T - sum, (long long)i);
    if (p < 0) break;
    res = (res * 2 - C(i - 1, pp)) % P;
    while (pp < p) (res += C(i, ++pp)) %= P;
    while (pp > p) (res -= C(i, pp--)) %= P;
    (ans += res * Inv) %= P;
  }
  printf("%lld\n", (ans + P) % P);
  return 0;
}
