#include <bits/stdc++.h>
using namespace std;
const long long int mod = 1e9 + 7;
long long int n, i, j, ans, T, a[200005], sum[200005];
vector<long long int> f(200005, 0), invf(200005, 0);
long long int mul(long long int a, long long int b) {
  return (((a % mod) * (b % mod)) % mod);
}
long long int bpow(long long int a, long long int x) {
  long long int res = 1;
  while (x > 0) {
    if (x & 1) res = mul(res, a);
    x = x >> 1;
    a = mul(a, a);
  }
  return (res % mod);
}
long long int inv(long long int a) { return bpow(a, mod - 2); }
long long int c(long long int k, long long int n) {
  return mul(mul(f[n], invf[n - k]), invf[k]);
}
int main() {
  cin >> n >> T;
  long long int res = 1;
  sum[0] = 0;
  f[0] = 1;
  invf[0] = 1;
  for (i = 1; i <= n; i++) {
    cin >> a[i];
    sum[i] = sum[i - 1] + a[i];
    res = (res * i) % mod;
    f[i] = res;
    invf[i] = inv(res);
  }
  sum[n + 1] = sum[n] + 1e9;
  if (sum[n] <= T) {
    i = n;
  } else {
    for (i = 1; i <= n; i++) {
      if ((T - sum[i]) < 0) break;
    }
    i--;
  }
  ans = 0;
  long long int cnt = 0;
  while (T - sum[i + 1] <= i) {
    for (j = max(0ll, T - sum[i + 1]); j <= min(T - sum[i], i); j++) {
      long long int res = c(j, i);
      if (j == (T - sum[i + 1])) res = (res * invf[2]) % mod;
      ans = (ans + (((res * i) % mod) * (inv(bpow(2, i)) % mod)) % mod) % mod;
    }
    i--;
  }
  cout << ans;
}
