#include <bits/stdc++.h>
const long long modVal = 1000000007;
using namespace std;
int main() {
  int N, K;
  cin >> N >> K;
  int a[N];
  int maxA[N];
  int prev = 0;
  for (int i = 0; i < N; i++) {
    cin >> a[i];
    maxA[i] = prev + a[i];
    prev += a[i];
  }
  long long **dp = (long long **)malloc(sizeof(long long **) * N);
  for (int i = 0; i < N; i++) {
    dp[i] = (long long *)malloc(sizeof(long long *) * (K + 1));
    for (int j = 0; j < K + 1; j++) {
      dp[i][j] = -1;
    }
  }
  function<long long(int, int)> getDp;
  getDp = [&](int i, int k) -> long long {
    if (i == 0 && a[i] < k) {
      return 0;
    }
    if (i == 0 && a[i] >= k) {
      return 1;
    }
    if (dp[i][k] != -1) {
      return dp[i][k];
    }
    long long output = 0;
    for (int p = 0; p <= k && p <= a[i]; p++) {
      if (k - p > maxA[i - 1]) {
        continue;
      }
      output += getDp(i - 1, k - p) % modVal;
      output %= modVal;
    }
    dp[i][k] = output;
    return output;
  };
  for (int i = 0; i < N; i++) {
    getDp(i, K);
  }
  cout << getDp(N - 1, K);
  return 0;
}
