#include <bits/stdc++.h>
using namespace std;
long long getNumberOfWays(vector<int> limits, int n, int k) {
  long long out = 0;
  vector<long long> dp(k + 1, 0);
  dp[0] = 1;
  for (int children = 1; children <= n; children++) {
    vector<long long> stepSum(k + 2, 0);
    for (int iter = k; iter >= 0; iter--) {
      if (iter + 1 <= min(iter + limits[children - 1], k)) {
        stepSum[iter + 1] += dp[iter];
        if (stepSum[iter + 1] >= (long long)1e9 + 7)
          stepSum[iter + 1] -= (long long)1e9 + 7;
        stepSum[min(iter + limits[children - 1], k) + 1] -= dp[iter];
        if (stepSum[min(iter + limits[children - 1], k) + 1] <=
            -1 * ((long long)1e9 + 7))
          stepSum[min(iter + limits[children - 1], k) + 1] +=
              (long long)1e9 + 7;
      }
    }
    long long inc = 0;
    for (int i = 0; i < k + 1; i++) {
      inc += stepSum[i];
      dp[i] += inc;
    }
  }
  out = dp[k];
  return out;
}
int main() {
  int n = 0, k = 0;
  cin >> n >> k;
  vector<int> limits(n, 0);
  for (int i = 0; i < n; i++) cin >> limits[i];
  cout << getNumberOfWays(limits, n, k) << endl;
  return 0;
}
