#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long int n, k;
  cin >> n >> k;
  long long int ar[n + 1];
  for (long long int i = 1; i <= n; i++) cin >> ar[i];
  long long int dp[n + 1][k + 1];
  memset(dp, 0, sizeof(dp));
  long long int predp[n + 1][k + 1];
  memset(predp, 0, sizeof(predp));
  for (long long int i = 0; i <= min(ar[1], k); i++) {
    dp[1][i] = 1;
  }
  predp[1][0] = dp[1][0];
  for (long long int i = 1; i <= k; i++) {
    predp[1][i] = predp[1][i - 1] + dp[1][i];
    predp[1][i] %= 1000000007;
  }
  for (long long int i = 2; i <= n; i++) {
    long long int e = ar[i];
    for (long long int j = 0; j <= k; j++) {
      long long int tmp = j - e;
      if (tmp < 0) tmp = 0;
      if (tmp == 0)
        dp[i][j] = predp[i - 1][j];
      else
        dp[i][j] = predp[i - 1][j] - predp[i - 1][tmp - 1];
      dp[i][j] %= 1000000007;
      predp[i][j] = (j - 1 >= 0 ? predp[i][j - 1] : 0) + dp[i][j];
      predp[i][j] %= 1000000007;
    }
  }
  cout << dp[n][k] << '\n';
  return 0;
}
