#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  clock_t launch = clock();
  long long t = 1;
  while (t--) {
    long long n, k;
    cin >> n >> k;
    long long dp[n + 1][k + 1], psum[n + 1][k + 1], cd[n + 1];
    memset(dp, 0, sizeof dp);
    memset(psum, 0, sizeof psum);
    for (long long i = 0; i < k + 1; i++) psum[0][i] = 1;
    for (long long i = 1; i < n + 1; i++) cin >> cd[i];
    for (long long i = 1; i < n + 1; i++) {
      for (long long j = 0; j < k + 1; j++) {
        if (j - cd[i] <= 0)
          dp[i][j] = psum[i - 1][j];
        else
          dp[i][j] = psum[i - 1][j] - psum[i - 1][j - cd[i] - 1];
      }
      for (long long j = 0; j < k + 1; j++) {
        if (j)
          psum[i][j] = (psum[i][j - 1] + dp[i][j]) % 1000000007;
        else
          psum[i][j] = 1;
      }
    }
    cout << dp[n][k] << endl;
  }
  clog << ((long double)(clock() - launch) / CLOCKS_PER_SEC) << "\n";
  return 0;
}
