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