#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1000000007LL;
signed main() {
  long long n, k;
  cin >> n >> k;
  vector<vector<long long> > dp(n + 1, vector<long long>(3 * k + 1, 0LL));
  vector<long long> a(n);
  for (long long i = 0; i < n; i++) cin >> a[i];
  dp[0][0] = 1LL;
  for (long long i = 0; i < n; i++) {
    for (long long j = 0; j <= k; j++) {
      dp[i + 1][j] += dp[i][j];
      dp[i + 1][j] %= MOD;
      dp[i + 1][j + a[i] + 1] -= dp[i][j];
      dp[i + 1][j + a[i] + 1] %= MOD;
    }
    for (long long j = 1; j <= 2 * k; j++) {
      dp[i + 1][j] += dp[i + 1][j - 1];
      dp[i + 1][j] %= MOD;
    }
  }
  cout << dp[n][k] % MOD << endl;
  return 0;
}
