#include <bits/stdc++.h>
using namespace std;
int dp[100005][105];
int segtree[400005][105];
const int MOD = 1e9 + 7;
int n, k;
void update(int v, int l, int r, int pos, int val, int child) {
  if (l == r) {
    segtree[v][child] = val;
    return;
  }
  int m = (l + r) / 2;
  if (pos <= m)
    update(2 * v, l, m, pos, val, child);
  else
    update(2 * v + 1, m + 1, r, pos, val, child);
  segtree[v][child] = (segtree[2 * v][child] + segtree[2 * v + 1][child]) % MOD;
}
int sum(int v, int l, int r, int ql, int qr, int child) {
  if (l > qr || r < ql) return 0;
  if (ql <= l && r <= qr) return segtree[v][child];
  return sum(2 * v, l, (l + r) / 2, ql, qr, child) +
         sum(2 * v + 1, (l + r) / 2 + 1, r, ql, qr, child);
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> k;
  dp[0][0] = 1;
  update(1, 0, k, 0, 1, 0);
  for (int child = 1; child <= n; child++) {
    dp[0][child] = 1;
    update(1, 0, k, 0, 1, child);
    int mx;
    cin >> mx;
    for (int candle = 1; candle <= k; ++candle) {
      dp[candle][child] = (dp[candle][child] + sum(1, 0, k, max(0, candle - mx),
                                                   candle, child - 1)) %
                          MOD;
      update(1, 0, k, candle, dp[candle][child], child);
    }
  }
  cout << dp[k][n];
}
