#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
int main() {
  int n, k;
  cin >> n >> k;
  int a[n];
  vector<long long> dp(k + 1);
  dp[0] = 1;
  for (int i = 0; i < n; i++) cin >> a[i];
  for (int i = 0; i < n; i++) {
    vector<long long> dp1(k + 1);
    vector<long long> fake(k + 1);
    for (int already = 0; already <= k; already++) {
      fake[already] += dp[already];
      if (already + a[i] < k) fake[already + a[i] + 1] += (-dp[already]);
    }
    for (int j = 1; j <= k; j++) {
      fake[j] += fake[j - 1];
      fake[j] %= mod;
    }
    for (int j = 0; j <= k; j++) {
      dp1[j] += fake[j];
      dp1[j] %= mod;
    }
    dp = dp1;
  }
  cout << dp[k] % mod << endl;
}
