#include <bits/stdc++.h>
using namespace std;
map<pair<long long, long long>, long long> memo;
vector<long long> a, suff;
long long n, k;
const long long mod = 1e9 + 7;
long long solve(long long i, long long k) {
  if (memo.count({i, k})) return memo[{i, k}];
  if (k < 0) return 0;
  if (k > suff[i]) return 0;
  if (i == n) {
    return k == 0;
  }
  long long ans = 0;
  for (long long j = 0; j <= a[i]; j++) {
    ans += solve(i + 1, k - j);
    ans %= mod;
  }
  return memo[{i, k}] = ans;
}
int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> n >> k;
  a.resize(n);
  suff.resize(n);
  for (long long i = 0; i < n; i++) {
    cin >> a[i];
  }
  suff[n - 1] = a[n - 1];
  for (long long i = n - 2; i >= 0; i--) {
    suff[i] = a[i] + suff[i + 1];
  }
  cout << solve(0, k) << '\n';
  ;
}
