#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1e9 + 7;
int32_t main() {
  long long n, k;
  cin >> n >> k;
  long long a[n];
  for (long long i = 0; i < n; i++) cin >> a[i];
  vector<vector<long long>> dp(n + 1, vector<long long>(k + 1));
  vector<vector<long long>> pre(n + 1, vector<long long>(k + 1));
  for (long long i = 0; i <= n; i++) {
    for (long long j = 0; j <= k; j++) {
      if (j == 0 || i == 0) {
        dp[i][j] = 1;
        pre[i][j] = 1;
      } else if (j > a[i - 1]) {
        dp[i][j] = 0;
        pre[i][j] = pre[i][j - 1];
      } else {
        dp[i][j] = pre[i - 1][j];
        pre[i][j] = (pre[i][j - 1] + dp[i][j]) % MOD;
      }
    }
  }
  cout << dp[n][k] << "\n";
  return 0;
}
