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