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