#include <bits/stdc++.h>
using namespace std;
const long long mx = 2000009;
long long dp[100009];
long long pre[100009];
int main() {
  long long n, k;
  cin >> n >> k;
  dp[0] = 1;
  for (long long i = 0; i < n; i++) {
    long long x;
    cin >> x;
    for (long long used = k; used >= 0; used--) {
      long long suru = used + 1;
      long long ses = used + min(x, k - used);
      if (suru <= ses) {
        pre[suru] += dp[used], pre[ses + 1] -= dp[used];
        pre[suru] += 1000000007;
        pre[ses + 1] = (pre[ses] + 1000000007) % 1000000007;
      }
    }
    for (long long i = 1; i <= k; i++) {
      pre[i] += pre[i - 1];
      pre[i] %= 1000000007;
      dp[i] += pre[i];
      dp[i] %= 1000000007;
    }
    for (long long i = 0; i <= k; i++) pre[i] = 0;
  }
  cout << dp[k] << '\n';
}
