#include <bits/stdc++.h>
using namespace std;
int main() {
  long n, k;
  cin >> n >> k;
  vector<long> a;
  long x;
  for (long i = 0; i < n; i++) {
    cin >> x;
    a.push_back(x);
  }
  vector<long long> dp(k + 1), prf(k + 1);
  dp[0] = 1;
  long lo, hi;
  for (long i = 0; i < n; i++) {
    for (long s = 0; s <= k; s++) prf[s] = 0;
    for (long s = 0; s <= k; s++) {
      lo = s + 1;
      hi = s + min(a[i], k - s);
      if (lo <= hi) {
        prf[lo] = (prf[lo] + dp[s]) % 1000000007;
        if (hi < k) prf[hi + 1] = (prf[hi + 1] - dp[s]) % 1000000007;
      }
    }
    dp[0] = (dp[0] + prf[0]) % 1000000007;
    for (long s = 1; s <= k; s++) {
      prf[s] = (prf[s - 1] + prf[s]) % 1000000007;
      dp[s] = (dp[s] + prf[s]) % 1000000007;
    }
  }
  cout << dp[k] << endl;
}
