#include <bits/stdc++.h>
using namespace std;
const int MD = 1e9 + 7;
int main() {
  int n, k;
  cin >> n >> k;
  vector<int> a(n, 0);
  for (int i = 0; i < n; i++) cin >> a[i];
  vector<vector<long long>> dp(n + 1, vector<long long>(k + 1, 0));
  function<long long(int, int)> solve = [&](int i, int k) -> long long {
    if (i == n && k == 0) {
      return 1;
    } else if (i == n && k) {
      return 0;
    }
    if (dp[i][k] != -1) {
      return dp[i][k];
    }
    long long nways = 0;
    for (int bal = 0; bal <= a[i]; bal++) {
      if (k - bal < 0) {
        break;
      }
      nways = (nways + solve(i + 1, k - bal)) % MD;
    }
    return dp[i][k] = nways;
  };
  dp[0][0] = 1;
  vector<vector<long long>> prefix(n + 1, vector<long long>(k + 1, 0));
  prefix[0][0] = 1;
  for (int i = 1; i <= n; i++) {
    prefix[i][0] = 1;
  }
  for (int i = 1; i <= k; i++) {
    prefix[0][i] = 1;
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 0; j <= k; j++) {
      long long right = prefix[i - 1][j];
      long long left = 0;
      if (j - a[i - 1] - 1 >= 0) left = prefix[i - 1][j - a[i - 1] - 1];
      dp[i][j] = (dp[i][j] + (right - left)) % MD;
      prefix[i][j] = (prefix[i][j - 1] + dp[i][j]) % MD;
    }
  }
  cout << dp[n][k] << endl;
  return 0;
}
