#include <bits/stdc++.h>
int d_, x_, y_;
void gcd_(int a, int b) {
  if (b == 0)
    d_ = a, x_ = 1, y_ = 0;
  else {
    int tmp;
    gcd_(b, a % b);
    tmp = x_ - a / b * y_, x_ = y_, y_ = tmp;
  }
}
int inv(int a) {
  gcd_(a, 1000000007);
  return x_;
}
int ff[200000 + 1], gg[200000 + 1];
void init() {
  int i, f;
  f = 1;
  for (i = 0; i <= 200000; i++) {
    gg[i] = inv(ff[i] = f);
    f = (long long)f * (i + 1) % 1000000007;
  }
}
int choose(int n, int k) {
  return (long long)ff[n] * gg[k] % 1000000007 * gg[n - k] % 1000000007;
}
int main() {
  int n, k, ans;
  long long s, x, p;
  init();
  scanf("%d%lld", &n, &s);
  ans = 0, x = 1, p = 1;
  for (k = 1; k <= n; k++) {
    int t;
    long long s_;
    scanf("%d", &t);
    if ((s_ = s - t) < 0) break;
    x = (x * 2 - (k - 1 >= s ? choose(k - 1, s) : 0)) % 1000000007;
    if (s_ < k) {
      if (s > k) s = k;
      while (s > s_) x = (x - choose(k, s--)) % 1000000007;
    } else
      s = s_;
    ans =
        (ans + x * (p = p * ((1000000007 + 1) / 2) % 1000000007)) % 1000000007;
  }
  if (ans < 0) ans += 1000000007;
  printf("%d\n", ans);
  return 0;
}
