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