#include <bits/stdc++.h>
using namespace std;
void ga(int N, int *A) {
  for (int i(0); i < N; i++) scanf("%d", A + i);
}
long long pw(long long n, long long k) {
  long long r(1);
  while (k) {
    if (k & 1) r *= n, r %= (1000000007);
    n *= n, n %= (1000000007), k >>= 1;
  }
  return r;
}
long long inv(long long a) { return pw(a, (1000000007) - 2); }
long long f[(1 << 20)] = {1, 1}, I[(1 << 20)] = {1, 1}, J[(1 << 20)] = {1, 1};
void pre() {
  for (int k(2); k < (1 << 20); k++)
    f[k] = f[k - 1] * k % (1000000007),
    J[k] =
        -(1000000007) / k * J[(1000000007) % k] % (1000000007) + (1000000007),
    I[k] = I[k - 1] * J[k] % (1000000007);
}
long long C(int N, int K) {
  return N < K ? 0 : (f[N] * I[K] % (1000000007)) * I[N - K] % (1000000007);
}
long long N, T, S[(1 << 20)], O;
int main(void) {
  pre();
  scanf("%lld%lld", &N, &T), S[N] = T + 1;
  for (int i(0); i < N; i++) scanf("%lld", S + i);
  for (int k(1); k < N; k++) S[k] += S[k - 1];
  for (int i(0); i < N; i++) {
    long long l = max(T - S[i + 1], 0ll), r = min(T - S[i] + 1, i + 2ll);
    if (l > r) continue;
    for (int k(l); k < r + 1; k++) {
      if (S[i] + k > T) continue;
      if (S[i + 1] + k <= T) {
        if (S[i + 1] + k + 1 > T)
          O = (O + (i + 1) * C(i + 1, k) % (1000000007) * inv(pw(2, i + 2)) %
                       (1000000007)) %
              (1000000007);
        continue;
      }
      if (S[i] + k > T) continue;
      O = (O + (i + 1) * C(i + 1, k) % (1000000007) * inv(pw(2, i + 1)) %
                   (1000000007)) %
          (1000000007);
    }
  }
  printf("%lld\n", O);
  return 0;
}
