#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9 + 7;
int main() {
  int n, k;
  cin >> n >> k;
  vector<vector<long long>> dp(n + 1, vector<long long>(k + 1, 0));
  vector<long long> a(n + 1);
  for (int i = 1; i <= n; ++i) cin >> a[i];
  for (int j = 0; j <= k; ++j) dp[0][j] = 1;
  for (int i = 1; i <= n; ++i) {
    for (int j = 0; j <= k; ++j) {
      if (j) dp[i][j] = dp[i][j - 1];
      dp[i][j] += dp[i - 1][j];
      if (j - a[i] - 1 >= 0) dp[i][j] += MOD - dp[i - 1][j - a[i] - 1];
      dp[i][j] %= MOD;
    }
  }
  cout << (MOD + dp[n][k] - dp[n][k - 1]) % MOD;
  return 0;
}
