#include <bits/stdc++.h>
using namespace std;
int32_t 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 dp[k + 1][n + 1];
  memset(dp, 0, sizeof dp);
  long long sm[k + 1][n + 1];
  sm[0][0] = 1;
  dp[0][0] = 1;
  for (long long j = 1; j <= k; j++) sm[j][0] = 1;
  for (long long i = 0; i <= k; i++) {
    for (long long j = 1; j <= n; j++) {
      if (i == 0) {
        dp[i][j] = 1;
        sm[i][j] = 1;
      } else {
        long long x = min(i, a[j - 1]);
        long long s = 0;
        s += sm[i][j - 1];
        if (i - x > 0) s -= sm[i - x - 1][j - 1];
        sm[i][j] = (sm[i - 1][j] + s) % 1000000007;
        dp[i][j] = s;
      }
    }
  }
  cout << dp[k][n];
}
