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