#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 counter = min(k, arr[1]);
  for (int i = (0); i <= (counter); i++) {
    pre[i] = 1;
  }
  pre2[0] = pre[0];
  for (int i = (1); i <= (k); i++) {
    pre2[i] = (pre2[i - 1] + pre[i]) % mod;
  }
  int64_t big;
  for (int i = (2); i <= (n); i++) {
    counter = counter + arr[i];
    counter = min(counter, k);
    for (int j = (0); j <= (counter); j++) {
      big = j - arr[i];
      if (big > 0) {
        big--;
        pre[j] = pre2[j] - pre2[big];
      } else
        pre[j] = pre2[j];
    }
    for (int nn = (counter + 1); nn <= (k); nn++) pre[nn] = 0;
    pre2[0] = pre[0];
    for (int pair<int, int> = (1); pair<int, int> <= (min(k, counter));
         pair<int, int> ++) {
      pre2[pair<int, int>] =
          (pre2[pair<int, int> - 1] + pre[pair<int, int>]) % mod;
    }
  }
  cout << pre[k] << endl;
}
