#include <bits/stdc++.h>
using namespace std;
long long int mod = 1e9 + 7;
int main() {
  long long int n, m, k, x;
  cin >> n >> k;
  vector<long long int> vec(n + 1, 0);
  for (int i = 1; i <= n; i++) cin >> vec[i];
  vector<vector<long long int>> dp(n + 1, vector<long long int>(k + 1, 0)),
      prefix(n + 1, vector<long long int>(k + 1, 0));
  for (int i = 0; i <= n; i++) {
    dp[i][0] = 1;
  }
  for (long long int i = 1; i <= n; i++) {
    for (long long int j = 1; j <= k; j++) {
      dp[i - 1][j] += dp[i - 1][j - 1];
      if (j > vec[i])
        dp[i][j] = (dp[i - 1][j] % mod - dp[i - 1][j - vec[i] - 1] % mod) % mod;
      else
        dp[i][j] = dp[i - 1][j] % mod;
    }
  }
  cout << dp[n][k] % mod;
  return 0;
}
