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