#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 10, mod = 1e9 + 7;
long long n, T, ans;
long long t[N], pre[N], p[N];
long long fac[N], inv[N];
long long qpow(long long a, long long b) {
  long long ret = 1;
  for (; b; b >>= 1) {
    if (b & 1) ret = ret * a % mod;
    a = a * a % mod;
  }
  return ret;
}
void prework(int n) {
  fac[0] = inv[0] = inv[1] = 1;
  for (long long i = 1; i <= n; i++) fac[i] = fac[i - 1] * i % mod;
  for (long long i = 2; i <= n; i++)
    inv[i] = (mod - mod / i) * inv[mod % i] % mod;
  for (long long i = 2; i <= n; i++) inv[i] = inv[i] * inv[i - 1] % mod;
}
long long C(long long n, long long m) {
  return fac[n] * inv[m] % mod * inv[n - m] % mod;
}
int main() {
  cin >> n >> T;
  prework(n);
  for (long long i = 1; i <= n; i++) {
    scanf("%lld", &t[i]);
    pre[i] = pre[i - 1] + t[i];
  }
  t[++n] = T + 1, pre[n] = pre[n - 1] + t[n];
  for (long long i = 0; i <= n - 1; i++) {
    if (pre[i] > T) break;
    if (pre[i + 1] + i + 1 <= T) continue;
    long long pw = qpow(qpow(2, i + 1), mod - 2);
    long long l = max(0ll, T - pre[i + 1] + 1), r = min(T - pre[i], i);
    for (long long k = l; k <= r; k++)
      (ans += 1ll * i * C(i, k) % mod * pw % mod) %= mod;
    l = max(0ll, T - pre[i + 1]), r = min(T - pre[i], i);
    for (long long k = l; k <= r; k++)
      (ans += 1ll * i * C(i, k) % mod * pw % mod) %= mod;
  }
  printf("%lld\n", ans);
  return 0;
}
