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