#include <bits/stdc++.h>
using namespace std;
const int N = 200005;
const int MOD = 1000000007;
const int INV = (MOD + 1) / 2;
long long f[N], rev[N], fac[N];
long long quickPow(long long a, int b) {
  long long res = 1;
  for (; b; b >>= 1) {
    if (b & 1) {
      res = res * a % MOD;
    }
    a = a * a % MOD;
  }
  return res;
}
long long C(int a, int b) {
  if (a < b) {
    return 0;
  }
  return fac[a] * rev[b] % MOD * rev[a - b] % MOD;
}
int main() {
  int n;
  long long T;
  cin >> n >> T;
  fac[0] = 1;
  for (int i = 1; i <= n; i++) {
    fac[i] = fac[i - 1] * i % MOD;
  }
  rev[n] = quickPow(fac[n], MOD - 2);
  for (int i = n; i >= 1; i--) {
    rev[i - 1] = rev[i] * i % MOD;
  }
  f[0] = 1;
  for (int i = 1; i <= n; i++) {
    int t;
    cin >> t;
    long long a = T;
    long long b = T - t;
    T = b;
    if (b < 0) {
      break;
    }
    f[i] = 2 * f[i - 1] % MOD;
    if (b >= i) {
      continue;
    }
    long long res = 0;
    for (int j = b; j < i && j <= a; j++) {
      res += C(i - 1, j) * (1 + (j > b)) % MOD;
    }
    f[i] = (f[i] - res % MOD + MOD) % MOD;
  }
  long long ans = 0, mul = 1;
  for (int i = 1; i <= n; i++) {
    mul = mul * INV % MOD;
    ans = (ans + f[i] * mul % MOD) % MOD;
  }
  cout << ans << endl;
  return 0;
}
