#include <bits/stdc++.h>
using namespace std;
const unsigned long long MOD = 1000000007;
unsigned long long a[200001], f[200001][201], h[200001][201];
unsigned int n, k;
unsigned long long sd(unsigned int i, unsigned int j) {
  if (i <= a[j])
    return 0;
  else
    return h[i - a[j] - 1][j - 1];
}
int main() {
  cin >> n >> k;
  for (unsigned int i = 0; i < n; ++i) cin >> a[i];
  for (unsigned int i = 0; i <= a[0]; ++i) {
    f[i][0] = 1;
    h[i][0] = i + 1;
  }
  for (unsigned int i = a[0] + 1; i <= k; ++i) h[i][0] += h[i - 1][0];
  for (unsigned int i = 0; i <= k; ++i) {
    for (unsigned int j = 1; j < n; ++j) {
      f[i][j] = (h[i][j - 1] - sd(i, j));
      f[i][j] = f[i][j] % MOD;
      h[i][j] = h[i - 1][j] + f[i][j];
    }
  }
  cout << f[k][n - 1];
}
