#include <bits/stdc++.h>
using namespace std;
int64_t n, k;
const int mod = 1000000007;
int main() {
  cin >> n >> k;
  int64_t pre[100008];
  int64_t pre2[100008];
  int64_t arr[100008];
  for (int i = (1); i <= (n); i++) {
    cin >> arr[i];
  }
  for (int i = 0; i < 100008; i++) {
    pre[i] = 0;
    pre2[i] = 0;
  }
  int64_t k2 = min(arr[1], k);
  for (int i = (0); i <= (k2); i++) {
    pre[i] = 1;
  }
  pre2[0] = pre[0];
  int64_t counter = 0;
  for (int i = (1); i <= (100005); i++) {
    pre2[i] = (pre2[i - 1] + pre[i]) % mod;
  }
  for (int i = (2); i <= (n); i++) {
    k2 = min(arr[i], k);
    counter = counter + k2;
    counter = min(counter, (int64_t)100000);
    for (int i = (0); i <= (counter); i++) {
      pre[i] = pre2[i];
    }
    for (int i = (counter + 1); i <= (100005); i++) pre[i] = 0;
    pre2[0] = pre[0];
    for (int i = (1); i <= (100005); i++) {
      pre2[i] = (pre2[i - 1] + pre[i]) % mod;
    }
  }
  cout << pre[k] << endl;
}
