#include <bits/stdc++.h>
using namespace std;
int main() {
  int mod = 1e9 + 7;
  int N, K;
  cin >> N >> K;
  vector<int> a(N);
  for (int i = 0; i < N; i++) cin >> a[i];
  vector<vector<long long>> dp(N, vector<long long>(K + 1, 0));
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < K + 1; j++) {
      if (j == 0) {
        dp[i][j] = 1;
        continue;
      }
      if (i == 0) {
        if (j <= a[i])
          dp[i][j] = 1;
        else
          dp[i][j] = 0;
        continue;
      }
      dp[i][j] = dp[i - 1][j] + dp[i][j - 1];
      if (j > a[i]) dp[i][j] -= dp[i - 1][j - 1 - a[i]];
      while (dp[i][j] > mod) dp[i][j] -= mod;
    }
  }
  cout << dp[N - 1][K] << endl;
  return 0;
}
