#include <bits/stdc++.h>
using namespace std;
int const MAXN = 110, MAXK = 100100, M = 1000000007;
int n, k, c[MAXN], dp[MAXK][MAXN], prefix[MAXK][MAXN];
void compute_prefix(int col) {
  int current = 0;
  for (int row = 0; row <= k; row++) {
    prefix[row][col] = (dp[row][col] + current) % M;
    current += (dp[row][col]) % M;
  }
}
int sum(int start, int end, int where) {
  if (start == 0) return prefix[end][where];
  return prefix[end][where] - prefix[start - 1][where];
}
void print() {
  cout << "DP state:\n";
  for (int i = 0; i <= k; i++) {
    for (int j = 0; j < n; j++) cout << dp[i][j] << " ";
    cout << "\n";
  }
  cout << "Prefix Sums:\n";
  for (int i = 0; i <= k; i++) {
    for (int j = 0; j < n; j++) cout << prefix[i][j] << " ";
    cout << "\n";
  }
}
int main() {
  cin >> n >> k;
  for (int i = 0; i < n; i++) cin >> c[i];
  for (int col = n - 1; col >= 0; col--) {
    if (col == n - 1) {
      for (int row = 0; row <= c[col]; row++) dp[row][col] = 1;
    } else {
      for (int row = 0; row <= k; row++) {
        int start = 0, end = min(row, c[col]);
        int add = max(0, row - c[col]);
        start += add, end += add;
        dp[row][col] = sum(start, end, col + 1);
      }
    }
    compute_prefix(col);
  }
  cout << dp[k][0];
}
