#include <bits/stdc++.h>
using namespace std;
const long long int mod = 1e9 + 7;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long int n, k;
  cin >> n >> k;
  long long int a[n];
  for (long long int i = 0; i < n; i++) cin >> a[i];
  long long int dp[k + 1][n], dp1[k + 1][n];
  memset(dp, 0, sizeof(dp));
  memset(dp1, 0, sizeof(dp1));
  for (long long int i = 0; i < n; i++) {
    dp[0][i] = 1;
    dp1[0][i] = 1;
  }
  for (long long int i = 1; i <= k; i++) {
    for (long long int j = 0; j < n; j++) {
      if (j == 0) {
        dp[i][j] = i == a[j] ? 1 : 0;
        dp1[i][j] = dp1[i - 1][j] + dp[i][j];
        dp1[i][j] %= mod;
      } else {
        dp[i][j] = a[j] < i ? dp1[i][j - 1] - dp1[i - a[j] - 1][j - 1] + mod
                            : dp1[i][j - 1];
        dp[i][j] %= mod;
        dp1[i][j] = dp1[i - 1][j] + dp[i][j];
        dp1[i][j] %= mod;
      }
    }
  }
  cout << dp[k][n - 1] << '\n';
}
