#include <bits/stdc++.h>
using namespace std;
const int T = 1e9 + 7;
const int maxn = 2e5 + 233;
long long fac[maxn], inv[maxn];
int exgcd(int a, int b, int &x, int &y) {
  if (b == 0) {
    x = 1;
    y = 0;
    return a;
  }
  int d = exgcd(b, a % b, y, x);
  y -= (a / b) * x;
  return d;
}
inline void add(long long &x, long long v) { x = (x + v) % T; }
inline int Inv(int i) {
  int x, y;
  exgcd(i, T, x, y);
  x = (x + T) % T;
  return x;
}
void init() {
  fac[0] = inv[0] = 1;
  for (int i = 1; i < maxn; i++) {
    fac[i] = fac[i - 1] * i % T;
    int x, y;
    exgcd(i, T, x, y);
    x = (x + T) % T;
    inv[i] = inv[i - 1] * x % T;
  }
}
long long inv2[maxn];
inline long long c(int n, int k) {
  if (k > n) return 0;
  return fac[n] * inv[k] % T * inv[n - k] % T * inv2[n] % T;
}
int t[maxn];
int main() {
  init();
  int n;
  long long tot;
  cin >> n >> tot;
  for (int i = 1; i <= n; i++) scanf("%d", &t[i]);
  long long cur = 0, ans = 0;
  inv2[1] = (T + 1) / 2;
  for (int i = 2; i <= n; i++) inv2[i] = (inv2[i - 1] * (T + 1) / 2) % T;
  for (int i = 1; i <= n; i++) {
    cur += t[i];
    if (cur > tot) break;
    if (cur + t[i + 1] + i < tot) continue;
    int l = tot - cur - t[i + 1], r = tot - cur;
    if (r > i) r = i;
    if (l >= 0) {
      if (i != n) {
        add(ans, c(i, l) * i % T * inv2[1] % T);
        l++;
      }
    } else
      l = 0;
    if (i == n) l = 0;
    for (int j = l; j <= r; j++) add(ans, c(i, j) * i % T);
  }
  cout << ans << endl;
  return 0;
}
