#include <bits/stdc++.h>
using namespace std;
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ;
  long long n, k;
  cin >> n >> k;
  long long a[n];
  for (long long i = 0; i < n; i++) cin >> a[i];
  long long dp[n + 1][k + 1], cum[n + 1][k + 1];
  for (long long i = 0; i <= n; i++) {
    long long sum = 0;
    for (long long j = 0; j <= k; j++) {
      if (j == 0) {
        dp[i][j] = 1;
      } else if (i == 0) {
        dp[i][j] = 0;
      } else {
        if (j - a[i - 1] - 1 >= 0)
          dp[i][j] = cum[i - 1][j] - cum[i - 1][j - a[i - 1] - 1];
        else {
          dp[i][j] = cum[i - 1][j];
        }
      }
      sum += dp[i][j];
      sum %= 1000000007;
      cum[i][j] = sum;
    }
  }
  cout << dp[n][k] << endl;
}
