#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
const long long maxn = 1e5 + 1;
long long n;
vector<vector<long long>> dp(n);
long long query(long long pos1, long long l, long long r) {
  l += maxn;
  r += maxn;
  long long res = 0;
  while (l <= r) {
    if (l % 2 == 1) res += dp[pos1][l++];
    if (r % 2 == 0) res += dp[pos1][r--];
    l /= 2;
    r /= 2;
  }
  return res % mod;
}
void change(long long pos1, long long pos2, long long val) {
  pos2 += maxn;
  dp[pos1][pos2] += val;
  for (pos2 /= 2; pos2 >= 1; pos2 /= 2) {
    dp[pos1][pos2] = dp[pos1][pos2 * 2] + dp[pos1][pos2 * 2 + 1];
  }
}
signed main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long k;
  cin >> n >> k;
  vector<long long> a(n);
  for (long long i = 0; i < n; i++) cin >> a[i];
  dp = vector<vector<long long>>(n, vector<long long>(2 * maxn));
  for (long long i = 0; i <= a[0]; i++) {
    change(0, i, 1);
    change(0, i + 1, -1);
  }
  for (long long i = 1; i < n; i++) {
    for (long long j = 0; j <= k; j++) {
      long long get = query(i - 1, 0, j);
      if (get > 0) {
        long long left = j, right = min(k, j + a[i]);
        change(i, left, get);
        change(i, right + 1, -get);
      }
    }
  }
  long long ans = query(n - 1, 0, k);
  cout << ans % mod;
  return 0;
}
