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