#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];
  int dp[n + 1][k + 1];
  for (int i = 0; i <= n; i++) dp[i][0] = 1;
  for (int j = 0; j <= k; j++) {
    dp[0][j] = 1;
  }
  for (int j = 1; j <= k; j++) {
    if (j <= a[0])
      dp[1][j] = 1;
    else
      dp[1][j] = 0;
  }
  for (int i = 2; i <= n; i++) {
    int st = 0;
    int csum = dp[i - 1][0];
    for (int j = 1; j <= k; j++) {
      if (a[i - 1] >= j) {
        csum += dp[i - 1][j];
        csum %= 1000000007;
        dp[i][j] = csum;
      } else {
        csum += dp[i - 1][j];
        csum -= dp[i - 1][st];
        csum %= 1000000007;
        st++;
        if (csum >= 0)
          dp[i][j] = csum;
        else
          dp[i][j] = 0;
      }
    }
  }
  cout << dp[n][k];
  return 0;
}
