#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k;
  cin >> n >> k;
  vector<vector<long long>> dp(n + 1, vector<long long>(k + 1, 0));
  vector<long long> pref(k + 1, 0);
  dp[0][0] = 1;
  for (int i = 1; i <= n; i++) {
    int a;
    cin >> a;
    pref[0] = dp[i - 1][0];
    for (int h = 1; h <= k; h++)
      pref[h] = (pref[h - 1] + dp[i - 1][h]) % 1000000007;
    for (int j = 0; j <= k; j++) {
      int l = pref[j];
      int r = (j > a) ? pref[j - a - 1] : 0;
      dp[i][j] = (dp[i][j] + (l - r)) % 1000000007;
    }
  }
  cout << dp[n][k];
  return 0;
}
