#include <bits/stdc++.h>
using namespace std;
long long f[200005], v[200005], p[200005], t[200005];
long long ksm(long long a, long long b) {
  long long ans = 1;
  while (b > 0) {
    if (b % 2 == 1) {
      ans = ans * a % 1000000007;
    }
    a = a * a % 1000000007;
    b /= 2;
  }
  return ans;
}
long long g(long long x, long long y) {
  return f[x] * v[x - y] % 1000000007 * v[y] % 1000000007;
}
int main() {
  long long i, j, l, r, n, m, k, sum = 0, ans = 0;
  f[0] = p[0] = 1;
  for (i = 1; i <= 200001; i++) {
    f[i] = f[i - 1] * i % 1000000007;
    p[i] = p[i - 1] * 500000004 % 1000000007;
  }
  v[200001] = ksm(f[200001], 1000000007 - 2);
  for (i = 200000; i >= 0; i--) {
    v[i] = v[i + 1] * (i + 1) % 1000000007;
  }
  cin >> n >> m;
  for (i = 1; i <= n; i++) cin >> t[i];
  t[++n] = m + 1;
  for (i = 1; i <= n && sum <= m; i++) {
    if (sum + i + t[i] > m) {
      l = max(0ll, m - sum - t[i] + 1);
      r = min(i - 1, m - sum);
      for (j = l; j <= r; j++) {
        ans = (ans + p[i] * g(i - 1, j) % 1000000007 * (i - 1) % 1000000007) %
              1000000007;
      }
      l = max(0ll, m - sum - t[i]);
      r = min(i - 1, m - sum);
      for (j = l; j <= r; j++) {
        ans = (ans + p[i] * g(i - 1, j) % 1000000007 * (i - 1) % 1000000007) %
              1000000007;
      }
    }
    sum += t[i];
  }
  cout << ans << endl;
  return 0;
}
