#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, K;
  cin >> N >> K;
  vector<int> a;
  for (int i = 0; i < N; i++) {
    int t;
    cin >> t;
    a.push_back(t);
  }
  vector<vector<int>> dp(N + 1, vector<int>(K + 1));
  for (int j = 0; j <= a[0]; j++) dp[1][j]++;
  for (int i = 2; i <= N; i++) {
    for (int j = 0; j <= K; j++) {
      if (dp[i - 1][j] != 0) {
        dp[i][j] += dp[i - 1][j];
        if (K >= j + a[i - 1]) dp[i][j + a[i - 1] + 1] -= dp[i - 1][j];
      }
    }
    for (int k = 1; k <= K; k++)
      dp[i][k] = (dp[i][k] + dp[i][k - 1]) % 1000000007;
  }
  cout << dp[N][K] << endl;
}
