#include <bits/stdc++.h>
using namespace std;
typedef pair<int, int> pii;
const int MOD = 1e9 + 7;
void mod(int &x) { x %= MOD; }
void mod(long long &x) { x %= (long long)MOD; }
const int mxN = 1e5 + 5;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, k;
  cin >> n >> k;
  vector<int> dp(k + 1);
  dp[0] = 1;
  for (register int child = 0; child < n; ++child) {
    int up_to;
    cin >> up_to;
    vector<int> lz(k + 1);
    for (register int used = k; used >= 0; --used) {
      int L = used + 1;
      int R = used + min(k - used, up_to);
      if (L <= R) {
        lz[L] += dp[used];
        mod(lz[L]);
        if (R + 1 <= k) {
          lz[R] -= dp[used];
          mod(lz[R]);
        }
      }
    }
    int prefix_sum = 0;
    for (int i = 0; i <= k; ++i) {
      prefix_sum += lz[i];
      mod(prefix_sum);
      dp[i] += prefix_sum;
      mod(dp[i]);
    }
  }
  mod(dp[k]);
  cout << dp[k] << endl;
  return 0;
}
