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