#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1e9 + 7;
void add(long long &x, long long val) {
  x += val;
  x %= MOD;
}
void subs(long long &x, long long val) {
  x -= val;
  x %= MOD;
}
long long dp[100005];
int main() {
  long long n, k, i, folosite;
  cin >> n >> k;
  dp[0] = 1;
  for (i = 1; i <= n; i++) {
    long long x;
    cin >> x;
    vector<long long> fake(k + 1);
    for (folosite = k; folosite >= 0; folosite--) {
      add(fake[folosite + 1], dp[folosite]);
      subs(fake[min(x, k - folosite) + folosite + 1], dp[folosite]);
    }
    for (folosite = 1; folosite <= k; folosite++) {
      add(fake[folosite], fake[folosite - 1]);
      add(dp[folosite], fake[folosite]);
    }
  }
  cout << dp[k];
  return 0;
}
