#include <bits/stdc++.h>
using namespace std;
const long long int N = 3e5 + 9;
const long long int inf = 1e16;
const long long int mod = 1e9 + 7;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long int t = 1;
  while (t--) {
    long long int n, k;
    cin >> n >> k;
    long long int a[n];
    for (int i = 0; i < n; i++) {
      cin >> a[i];
    }
    if (k == 0) {
      cout << 1 << '\n';
      return 0;
    }
    long long int dp[n][k];
    dp[0][0] = 0;
    long long int pres[k + 1];
    pres[0] = 0;
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < k; j++) {
        if (i == 0 && j == 0) {
          dp[i][j] = 1;
        } else if (i == 0) {
          dp[i][j] = 0;
        } else {
          dp[i][j] = (pres[j + 1] - pres[max(0ll, j - a[i])] + mod) % mod;
        }
      }
      for (int j = 1; j <= k; j++) {
        pres[j] = (pres[j - 1] + dp[i][j - 1]) % mod;
      }
    }
    cout << dp[n - 1][k - 1];
  }
}
