#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  long long n, t;
  cin >> n >> t;
  vector<long long> a((size_t)n);
  for (long long i = 0; i < n; i++) {
    cin >> a[i];
  }
  vector<long long> b((size_t)n);
  for (long long i = 0; i < n; i++) {
    b[i] = (i == 0 ? 0 : b[i - 1]) + a[i];
  }
  auto norm = [&](long long x) {
    return (x % 1000000007 + 1000000007) % 1000000007;
  };
  function<long long(long long, long long)> power = [&](long long x,
                                                        long long y) {
    if (y == 0) {
      return (long long)1;
    } else {
      long long z = power(x, y / 2);
      return y % 2 == 0 ? norm(z * z) : norm(norm(z * z) * x);
    }
  };
  auto div = [&](long long x) { return power(x, norm(-2)); };
  vector<long long> factorial((size_t)n + 1, 1);
  for (long long i = 1; i <= n; i++) {
    factorial[i] = norm(factorial[i - 1] * i);
  }
  auto binomial = [&](long long x, long long y) {
    return x < y ? (long long)0
                 : norm(norm(factorial[x] * div(factorial[y])) *
                        div(factorial[x - y]));
  };
  long long o = 0;
  for (long long i = 0, d = div(2), p = 2, m = 1; i < n;
       i++, d = norm(d * div(2)), p = norm(p * 2 + binomial(i, m + 1)), m++) {
    if (b[i] + i + 1 <= t) {
      o = norm(o + 1);
    } else if (b[i] <= t) {
      for (; m > min(t - b[i], i + 1); m--) {
        p = norm(p - binomial(i + 1, m));
      }
      o = norm(o + norm(p * d));
    }
  }
  cout << o << endl;
  return 0;
}
