#include <bits/stdc++.h>
using namespace std;
long long fact[222222];
long long factinv[222222];
long long twopows[222222];
long long GetBinom(int n, int k) {
  if (k == 0) return 1;
  long long ret = fact[n];
  ret = (ret * factinv[k]) % 1000000007;
  ret = (ret * factinv[n - k]) % 1000000007;
  return ret;
}
long long GetSum(int n, long long low, long long high) {
  if (low > high) return 0;
  if (low == 0 && high == n) {
    return twopows[n];
  }
  long long ret = 0;
  for (int k = low; k <= high; k++) {
    ret += GetBinom(n, k);
    ret %= 1000000007;
  }
  return ret;
}
long long modpow(long long x, long long y) {
  long long xs = x;
  long long answer = 1;
  while (y) {
    if (y & 1) {
      answer = (answer * xs) % 1000000007;
    }
    y >>= 1;
    xs = (xs * xs) % 1000000007;
  }
  return answer;
}
long long times[222222];
int main() {
  int n;
  long long T;
  cin >> n >> T;
  fact[0] = factinv[0] = 1;
  twopows[0] = 1;
  for (int i = 1; i <= n + 1; i++) {
    fact[i] = (fact[i - 1] * i) % 1000000007;
    factinv[i] = modpow(fact[i], 1000000007 - 2);
    twopows[i] = twopows[i - 1] * 2 % 1000000007;
  }
  for (int i = 1; i <= n; i++) {
    cin >> times[i];
  }
  times[n + 1] = T + 1;
  long long ans = 0;
  long long cumul = 0;
  for (int i = 1; i <= n; i++) {
    cumul += times[i];
    long long twopow = modpow(twopows[i + 1], 1000000007 - 2);
    long long prob = 0;
    for (int ri = 0; ri <= 1; ri++) {
      long long up = T - cumul;
      long long low = T + 1 - cumul - times[i + 1] - ri;
      low = max(low, 0ll);
      up = min(up, (long long)i);
      prob += twopow * GetSum(i, low, up);
      prob %= 1000000007;
    }
    prob %= 1000000007;
    ans += (long long)i * prob % 1000000007;
  }
  ans %= 1000000007;
  cout << ans << endl;
}
