#include <bits/stdc++.h>
using namespace std;
const long long M = 1e9 + 7;
vector<long long> v;
unordered_map<string, long long> mp;
long long ways(long long k, long long i) {
  if (k == 0) return 1;
  if (i == v.size()) {
    return 0;
  }
  string s = to_string(k) + " " + to_string(i);
  if (mp.find(s) == mp.end()) {
    long long ans = 0;
    ans += (ways(k - 1, i) + ways(k, i + 1)) % M;
    if (k - 1 >= v[i]) {
      ans -= ways(k - 1 - v[i], i + 1);
    }
    ans = (ans + M) % M;
    mp[s] = ans;
  }
  return mp[s];
}
int main() {
  long long n, k;
  cin >> n >> k;
  for (long long i = 0; i < n; i++) {
    long long d;
    cin >> d;
    v.push_back(d);
  }
  cout << ways(k, 0) << endl;
  return 0;
}
