#include <bits/stdc++.h>
using namespace std;
int main(void) {
  long long n, k;
  cin >> n >> k;
  vector<long long> a(n);
  for (int i = 0; i < n; ++i) cin >> a[i];
  vector<vector<long long> > dp(n + 1, vector<long long>(k + 1, 0));
  dp[0][0] = 1;
  for (int i = 1; i <= n; ++i) {
    long long t = 0;
    for (int j = 0; j <= k; j++) {
      if (j <= a[i - 1])
        t += dp[i - 1][j];
      else
        t += (dp[i - 1][j] - dp[i - 1][j - a[i - 1] - 1]);
      t %= 1000000007;
      dp[i][j] = t;
    }
  }
  cout << dp[n][k] << endl;
}
