#include <bits/stdc++.h>
using namespace std;
vector<long long> a;
long long n, k;
vector<vector<long long> > dp;
long long dist(long long i, long long can) {
  if (i == n - 1 && a[i] < can)
    return 0;
  else if (i == n - 1)
    return 1;
  long long &ans = dp[i][can];
  if (ans != -1)
    return ans % 1000000007;
  else {
    ans = 0;
    for (int j = 0; j <= a[i]; j++) {
      ans += dist(i + 1, can - j);
      ans = ans % 1000000007;
    }
    return ans % 1000000007;
  }
  return ans;
}
int main() {
  cin >> n >> k;
  dp.resize(n + 1, vector<long long>(k + 1, -1));
  a.resize(n + 1);
  for (int i = 0; i < n; i++) cin >> a[i];
  cout << dist(0, k);
}
