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