#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int n, k;
  cin >> n >> k;
  vector<long long> pos(k + 1);
  const long long MOD = 1e9 + 7;
  pos[0] = 1;
  for (int i = 0; i < (n); ++i) {
    int a;
    cin >> a;
    vector<long long> next(k + 1);
    long long sum = 0;
    if (a > 0) {
      for (int j = 0; j < (k + 1); ++j) {
        sum = (sum + pos[j]) % MOD;
        if (j - a - 1 >= 0) sum = (sum + MOD - pos[j - a - 1]) % MOD;
        next[j] = sum;
      }
    }
    swap(next, pos);
  }
  cout << pos[k] << "\n";
}
