#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k;
  long long m = 1000000007;
  cin >> n >> k;
  vector<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++) {
    for (int j = 0; j <= k; j++) {
      dp[i][j] = 0;
    }
  }
  for (int i = 1; i <= n; i++) {
    dp[i][0] = 1;
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= k; j++) {
      if (j <= a[i - 1]) {
        dp[i][j] = ((long long)dp[i - 1][j] + dp[i][j - 1]) % m;
        if (dp[i][j] < 0) {
          dp[i][j] = dp[i][j] + m;
        }
      } else {
        dp[i][j] = max(0, dp[i][j - 1] - 1) % m;
        if (dp[i][j] < 0) {
          dp[i][j] = dp[i][j] + m;
        }
        if (dp[i][j] == 0) {
          break;
        }
      }
    }
  }
  cout << dp[n][k] << endl;
  return 0;
}
