#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int n, k;
  cin >> n >> k;
  vector<int> a(n);
  vector<long long> dp(k + 1);
  dp[0] = 1;
  for (int j = 0; j < n; j++) {
    int upto;
    cin >> upto;
    vector<long long> fake(k + 1);
    for (int used = k; used >= 0; used--) {
      int L = used + 1;
      int R = used + min(upto, k - used);
      if (L <= R) {
        fake[L] += dp[used];
        if (R + 1 <= k) {
          fake[R + 1] -= dp[used];
        }
      }
    }
    long long prefix_sum = 0;
    for (int i = 0; i <= k; i++) {
      prefix_sum = (prefix_sum + fake[i]) % mod;
      dp[i] = (dp[i] + prefix_sum) % mod;
    }
  }
  cout << dp[k] << '\n';
  return 0;
}
