#include <bits/stdc++.h>
using namespace std;
int M = 1000000007;
vector<int> memo;
vector<int> A;
vector<int> B;
int K;
int dfs(int d, int k) {
  if (d == A.size()) {
    return k == 0;
  }
  int x = d * (K + 1) + k;
  if (memo[x] >= 0) {
    return memo[x];
  }
  if (k > B[d]) {
    return memo[x] = 0;
  } else {
    int r = 0;
    for (int i = 0; i <= min(k, A[d]); i++) {
      r += dfs(d + 1, k - i);
      if (r >= M) r -= M;
    }
    return memo[x] = r;
  }
}
int main() {
  int n;
  scanf("%d%d", &n, &K);
  memo.resize(n * (K + 1) + 1);
  fill(memo.begin(), memo.end(), -1);
  A.resize(n);
  B.resize(n);
  for (int i = 0; i < n; i++) scanf("%d", &A[i]), B[i] = A[i];
  for (int i = n - 1; i; i--) B[i - 1] += B[i];
  printf("%d\n", dfs(0, K));
}
