#include <bits/stdc++.h>
using namespace std;
const int N = 200005, Mod = 1e9 + 7;
int n, F[N], I[N], Pw[N];
long long T, A[N];
inline int nCr(int a, int b) {
  if (a < 0 || b < 0 || b > a) return 0;
  return (F[a] * 1LL * I[b] % Mod * I[a - b] % Mod);
}
int main() {
  scanf("%d%lld", &n, &T);
  for (int i = 1; i <= n; i++) scanf("%lld", &A[i]);
  for (int i = F[0] = 1; i < N; i++) F[i] = 1LL * F[i - 1] * i % Mod;
  I[0] = I[1] = 1;
  for (int i = 2; i < N; i++) I[i] = Mod - (Mod / i) * 1LL * I[Mod % i] % Mod;
  for (int i = Pw[0] = 1; i < N; i++) Pw[i] = 1LL * Pw[i - 1] * I[2] % Mod;
  for (int i = 1; i < N; i++) I[i] = 1LL * I[i] * I[i - 1] % Mod;
  int Exp = 0, SM = 0, Nw = -1;
  for (int i = 1; i <= n; i++) {
    A[i] += A[i - 1];
    if (A[i] > T) break;
    SM = SM * 2LL % Mod;
    SM = (SM - nCr(i - 1, Nw) + Mod) % Mod;
    if (A[i] + i <= T) {
      Exp = (Exp + 1) % Mod;
      continue;
    }
    int t = min(T - A[i], i * 1LL);
    while (Nw < t) SM = (SM + nCr(i, ++Nw)) % Mod;
    while (Nw > t) SM = (SM - nCr(i, Nw--) + Mod) % Mod;
    Exp = (Exp + 1LL * Pw[i] * SM) % Mod;
  }
  return !printf("%d\n", Exp);
}
