#include <bits/stdc++.h>
using namespace std;
void file() {}
const long long maxn = 2e5 + 1, mod = 1e9 + 7;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int n, k;
  cin >> n >> k;
  vector<long long> dp(k + 1);
  dp[0] = 1;
  for (long long i = 0; i < n; i++) {
    int x;
    cin >> x;
    vector<int> fake(k + 1);
    for (int j = k; j >= 0; --j) {
      int l = j + 1;
      int r = j + min(x, k - j) + 1;
      if (l < r && l <= k) {
        fake[l] += dp[j];
        fake[l] %= mod;
        fake[r] -= dp[j];
        fake[r] += mod;
        fake[r] %= mod;
      }
    }
    long long pre = 0;
    for (long long lel = 0; lel <= k; lel++) {
      pre += fake[lel];
      pre %= mod;
      dp[lel] += pre;
      dp[lel] %= mod;
    }
  }
  cout << dp[k] << "\n";
  return 0;
}
