#include <bits/stdc++.h>
const long long long long MOD = 1000000007;
using namespace std;
int32_t main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(0);
  ;
  long long n, k;
  cin >> n >> k;
  vector<long long> dp(k + 1);
  dp[0] = 1;
  for (long long child = 0; child < n; child++) {
    long long upto;
    cin >> upto;
    vector<long long> fake(k + 1);
    for (long long used = k; used >= 0; used--) {
      long long temp = dp[used];
      long long l = used + 1;
      long long r = used + min(upto, k - used);
      if (l <= r) {
        fake[l] += temp;
        fake[l] %= MOD;
        if (r + 1 <= k) {
          fake[r + 1] -= temp;
          fake[r + 1] %= MOD;
        }
      }
    }
    long long prefix = 0;
    for (long long i = 0; i <= k; i++) {
      prefix += fake[i];
      prefix %= MOD;
      dp[i] += prefix;
      dp[i] %= MOD;
    }
  }
  cout << dp[k] << '\n';
}
