#include <bits/stdc++.h>
using ll = long long;
const int C = 200001, M = 1000000007;
inline ll pow(ll a, ll b, ll M) {
  if (b == 0) return 1;
  ll c = 1;
  while (b > 0) {
    if (b % 2 == 1) c = (c * a) % M;
    b /= 2;
    a = (a * a) % M;
  }
  return c;
}
ll fac[C], af[C], a[C], ipw[C];
inline ll cn(ll n, ll k) {
  if (n < k || n < 0 || k < 0) return 0;
  return (((fac[n] * af[k]) % M) * af[n - k]) % M;
}
int main() {
  int n, i;
  ll T, k, tmp_lower, P = 0, summa = 0, rs1, rs2, rs3, completed_part = 0,
                      addit;
  fac[0] = af[0] = ipw[0] = 1;
  ipw[1] = pow(2, M - 2, M);
  for (i = 1; i < C; i++) fac[i] = (fac[i - 1] * i) % M;
  for (i = 1; i < C; i++) af[i] = (af[i - 1] * pow(i, M - 2, M)) % M;
  for (i = 2; i < C; i++) ipw[i] = (ipw[i - 1] * ipw[1]) % M;
  scanf("%d %lld", &n, &T);
  for (i = 0; i < n; i++) scanf("%lld", &a[i]);
  k = (((T - 1) < (i)) ? (T - 1) : (i));
  for (i = 0; i < n; i++) {
    tmp_lower = 0;
    for (; summa + a[i] - 1 + k >= T && k >= 0; k--) {
      tmp_lower = (tmp_lower + cn(i, k) * ipw[i]) % M;
    }
    rs1 = (cn(i, T - summa - a[i] - 1) * ipw[i + 1]) % M;
    rs2 = (cn(i, T - summa - a[i]) * ipw[i + 1]) % M;
    rs3 = (cn(i, T - summa - a[i]) * ipw[i + 1]) % M;
    completed_part = (completed_part + tmp_lower + rs1 + rs2 + rs3) % M;
    P = (P + (tmp_lower + rs2) * i + (rs1 + rs3) * (i + 1)) % M;
    summa += a[i];
    k = (((T - summa - 1) < (k)) ? (T - summa - 1) : (k));
  }
  addit = ((1 - completed_part) * n) % M;
  if (addit < 0) addit += M;
  printf("%lld\n", (P + addit) % M);
  return 0;
}
