#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using Graph = vector<vector<int>>;
using que_a = priority_queue<int, vector<int>, greater<int>>;
using que_d = priority_queue<int>;
using pint = pair<int, int>;
template <class T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <class T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
int n, k;
vector<int> a;
vector<vector<ll>> dp, flag;
ll rec(int ko, int nin) {
  if (flag.at(ko).at(nin)) return dp.at(ko).at(nin);
  flag.at(ko).at(nin) = 1;
  ll res = 0;
  int i = 0;
  while (ko - i >= 0 && i <= a.at(nin)) {
    res += rec(ko - i, nin - 1) % 1000000007;
    i++;
  }
  res = res % 1000000007;
  return dp.at(ko).at(nin) = res;
}
int main() {
  cin >> n >> k;
  a.resize(n + 1);
  for (int i = 1; i <= n; i++) cin >> a.at(i);
  dp.resize(k + 1, vector<ll>(n + 1));
  flag.resize(k + 1, vector<ll>(n + 1, 0));
  for (int i = 0; i < k + 1; i++) {
    dp.at(i).at(0) = 0;
    flag.at(i).at(0) = 1;
  }
  for (int i = 0; i < n + 1; i++) {
    dp.at(0).at(i) = 1;
    flag.at(0).at(i) = 1;
  }
  cout << rec(k, n) << endl;
  return 0;
}
