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