#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
inline void add_self(int& x, int y) {
  x += y;
  if (x >= mod) x -= mod;
  if (x < 0) x += mod;
}
inline void add_range(vector<int>& v, int x, int l, int r) {
  add_self(v[l], x);
  add_self(v[r + 1], -x);
}
void Main() {
  int N, K;
  cin >> N >> K;
  vector<int> a(N);
  for (int i = 0; i < N; ++i) {
    cin >> a[i];
  }
  vector<int> curr(K + 1, 0);
  curr[K] = 1;
  for (int i = 0; i < N; ++i) {
    vector<int> diff(K + 1, 0);
    add_range(diff, curr[0], 0, 0);
    for (int rem = 1; rem <= K; ++rem) {
      add_range(diff, curr[rem], rem - min(rem, a[i]), rem);
    }
    curr[0] = diff[0];
    for (int rem = 1; rem <= K; ++rem) {
      curr[rem] = curr[rem - 1];
      add_self(curr[rem], diff[rem]);
    }
  }
  cout << curr[0] << '\n';
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  Main();
}
