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