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