#include <bits/stdc++.h>
using namespace std;
int main() {
  int n = 0, K = 0;
  cin >> n >> K;
  long long arr[n];
  memset(arr, 0, sizeof(arr));
  for (int i = 0; i < n; i++) cin >> arr[i];
  vector<vector<long long>> dp(n, vector<long long>(K + 1, 0));
  vector<vector<long long>> prefixSum(n, vector<long long>(K + 1, 0));
  for (int i = 0; i < n; i++) {
    for (int k = 0; k <= K; k++) {
      if (i == 0) {
        if (arr[i] >= k) dp[i][k] = 1;
      } else {
        if (k - arr[i] > 0)
          dp[i][k] = prefixSum[i - 1][k] -
                     prefixSum[i - 1][k - arr[i] - 1] % (long long)(1e9 + 7);
        else
          dp[i][k] = prefixSum[i - 1][k] % (long long)(1e9 + 7);
      }
      if (k == 0)
        prefixSum[i][k] = (long long)dp[i][k];
      else
        prefixSum[i][k] = (long long)(dp[i][k] + prefixSum[i][k - 1]);
    }
  }
  cout << dp[n - 1][K] << endl;
  return 0;
}
