#include <bits/stdc++.h>
using namespace std;
const int MODN = 1e9 + 7;
vector<vector<int>> DP;
int solve(int pos, int len, int k, vector<int>& val) {
  if (k < 0) return 0;
  if (k == 0) return DP[pos][k] = 1;
  if (pos == len) {
    return DP[pos][k] = (k == 0);
  }
  if (DP[pos][k] != -1) return DP[pos][k];
  int ans = 0;
  for (int i = 0; i <= val[pos]; i++) {
    ans = (ans % MODN + solve(pos + 1, len, k - i, val) % MODN) % MODN;
  }
  return DP[pos][k] = ans;
}
int main() {
  int n, k, x;
  cin >> n >> k;
  vector<int> arr;
  DP.resize(n + 1, vector<int>(k + 1, -1));
  for (int i = 0; i < n; i++) {
    cin >> x;
    arr.push_back(x);
  }
  int ans = solve(0, n, k, arr);
  cout << ans << "\n";
  return 0;
}
