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