#include <bits/stdc++.h>
using namespace std;
map<pair<int, int>, int> m;
int f(int i, int *arr, int k, int n) {
  if (k == 0) {
    return 1;
  }
  if ((i == -1 && k != 0) || k < 0) {
    return 0;
  }
  if (m.count(make_pair(i, k)) > 0) {
    return m[make_pair(i, k)];
  }
  int ans = 0;
  for (int j = 0; j <= arr[i]; j++) {
    ans =
        (ans % 1000000007 + f(i - 1, arr, k - j, n) % 1000000007) % 1000000007;
  }
  m[make_pair(i, k)] = ans;
  return ans;
}
int main() {
  ifstream myFile("task.in");
  if (!myFile.fail()) {
    assert(freopen("task.in", "r", stdin));
  }
  int n, k;
  cin >> n >> k;
  int arr[n];
  for (int i = 0; i < n; i++) {
    cin >> arr[i];
  }
  int ans = f(n - 1, arr, k, n);
  cout << ans << endl;
  return 0;
}
