#include <bits/stdc++.h>
using namespace std;
long long a[1000001], fact[1000001], inv[1000001];
long long comb(long long k, long long n) {
  if (k == 0 || k == n) return 1;
  long long rez = fact[n];
  rez = rez * inv[n - k];
  rez %= 1000000007;
  rez = rez * inv[k];
  rez %= 1000000007;
  return rez;
}
long long mypow(long long x, long long p) {
  long long rez = 1;
  while (p > 0) {
    if (p % 2 == 1) {
      rez = (rez * x) % 1000000007;
    }
    x = (x * x) % 1000000007;
    p /= 2;
  }
  return rez;
}
int main() {
  long long n, m, i, sum, it, it2, ans, sus, jos;
  fact[0] = 1;
  inv[0] = 1;
  for (i = 1; i <= 500000; i++) {
    fact[i] = (fact[i - 1] * i) % 1000000007;
    inv[i] = mypow(fact[i], 1000000007 - 2);
  }
  cin >> n >> m;
  for (i = 1; i <= n; i++) {
    cin >> a[i];
    a[i]++;
  }
  sum = 0;
  it = 0;
  while (sum + a[it + 1] <= m) {
    it++;
    sum += a[it];
  }
  it2 = it;
  ans = 0;
  m++;
  for (i = 0; i <= it2; i++) {
    while (it2 < n && sum + a[it2 + 1] <= m) {
      it2++;
      sum += a[it2];
    }
    if (sum < m)
      it = it2;
    else
      it = it2 - 1;
    sus = comb(i, it);
    jos = mypow(2, it2);
    ans = (ans + it * (sus * mypow(jos, 1000000007 - 2) % 1000000007)) %
          1000000007;
    sum--;
  }
  cout << ans << '\n';
  return 0;
}
