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