#include <bits/stdc++.h>
using namespace std;
template <class T>
bool tomin(T &x, T y) {
  return x > y ? x = y, 1 : 0;
}
template <class T>
bool tomax(T &x, T y) {
  return x < y ? x = y, 1 : 0;
}
template <class T>
void read(T &x) {
  char c;
  x = 0;
  int f = 1;
  while (c = getchar(), c < '0' || c > '9')
    if (c == '-') f = -1;
  do x = (x << 3) + (x << 1) + (c ^ 48);
  while (c = getchar(), c >= '0' && c <= '9');
  x *= f;
}
const double Pi = acos(-1);
const int maxn = 2e5 + 5;
const int P = 1e9 + 7;
int n;
long long T, sum[maxn];
long long fact[maxn], finv[maxn], pw[maxn];
long long Com(int n, int m) {
  if (m < n) return 0;
  return fact[m] * finv[m - n] % P * finv[n] % P;
}
void Check(int &x, int y) {
  x += y;
  if (x >= P) x -= P;
}
int main() {
  srand(time(NULL));
  read(n), read(T);
  fact[0] = finv[0] = finv[1] = pw[0] = 1;
  for (int i = 1, i_ = n + 1; i <= i_; ++i) fact[i] = fact[i - 1] * i % P;
  for (int i = 2, i_ = n + 1; i <= i_; ++i)
    finv[i] = P - P / i * finv[P % i] % P;
  for (int i = 1, i_ = n + 1; i <= i_; ++i) finv[i] = finv[i - 1] * finv[i] % P;
  for (int i = 1, i_ = n + 1; i <= i_; ++i) pw[i] = pw[i - 1] * finv[2] % P;
  for (int i = 1, i_ = n; i <= i_; ++i) {
    read(sum[i]);
    sum[i] += sum[i - 1];
  }
  int ans = 0;
  long long L, R;
  for (int i = 1, i_ = n - 1; i <= i_; ++i) {
    if (sum[i] > T) break;
    R = min(T - sum[i], (long long)i);
    int sumc = 0;
    L = max((long long)0, T - sum[i + 1] + 1);
    if (L <= R) {
      for (int j = L, j_ = R; j <= j_; ++j) Check(sumc, Com(j, i));
      Check(ans, pw[i + 1] * sumc % P * i % P);
    }
    L = max((long long)0, T - sum[i + 1]);
    if (L <= R) {
      if (T >= sum[i + 1]) Check(sumc, Com(L, i));
      Check(ans, pw[i + 1] * sumc % P * i % P);
    }
  }
  L = 0, R = min(T - sum[n], (long long)n);
  int sumc = 0;
  for (int i = L, i_ = R; i <= i_; ++i) Check(sumc, Com(i, n));
  if (L <= R) Check(ans, pw[n] * sumc % P * n % P);
  printf("%d", ans);
  return 0;
}
