#include <bits/stdc++.h>
using namespace std;
int n, t[200005];
long long T, fac[200005], _inv[200005], inv[200005], h[200005], g[200005],
    s[200005], ans;
long long C(int n, int m) {
  if (m > n) return 1;
  return fac[n] * inv[m] % 1000000007 * inv[n - m] % 1000000007;
}
int main() {
  scanf("%d%lld", &n, &T);
  fac[0] = 1;
  for (int i = 1; i < 200005; i++) fac[i] = fac[i - 1] * i % 1000000007;
  _inv[0] = _inv[1] = 1;
  for (int i = 2; i < 200005; i++)
    _inv[i] =
        ((1000000007 - 1000000007 / i) * _inv[1000000007 % i]) % 1000000007;
  inv[0] = inv[1] = 1;
  for (int i = 2; i < 200005; i++) inv[i] = inv[i - 1] * _inv[i] % 1000000007;
  h[0] = 1;
  for (int i = 1; i < 200005; i++) h[i] = h[i - 1] * _inv[2] % 1000000007;
  for (int i = 1; i <= n; i++) {
    scanf("%d", &t[i]);
    s[i] = s[i - 1] + t[i];
    g[i] = g[i - 1] + t[i] + 1;
  }
  g[n + 1] = T + 1;
  for (int i = 1; i <= n; i++) {
    if (g[i] > T && T >= s[i - 1]) {
      for (int j = max(0ll, T - s[i] + 1); j <= i && s[i - 1] + j - 1 <= T;
           j++) {
        if (s[i - 1] + j > T) {
          ans = (ans + (long long)(i - 1) * h[i] % 1000000007 *
                           C(i - 1, j - 1) % 1000000007) %
                1000000007;
        } else {
          ans = (ans + (long long)(i - 1) * h[i] % 1000000007 * C(i, j) %
                           1000000007) %
                1000000007;
        }
      }
    }
  }
  for (int i = 0; i <= T - s[n]; i++)
    ans = (ans + (long long)n * h[n] % 1000000007 * C(n, i) % 1000000007) %
          1000000007;
  printf("%lld\n", ans);
}
