#include <bits/stdc++.h>
using namespace std;
int modd = 1e9 + 7;
int main() {
  int n, k;
  cin >> n >> k;
  long long ans[n + 1][k + 1];
  for (int i = 0; i <= n; i++) {
    ans[i][0] = 1;
    for (int j = 1; j <= k; j++) ans[i][j] = 0;
  }
  int arr[n];
  for (int i = 0; i < n; i++) cin >> arr[i];
  int key;
  for (int i = 1; i < n; i++) {
    key = arr[i];
    for (int j = i - 1; j >= 0; j--) {
      if (arr[j] > arr[j + 1])
        arr[j + 1] = arr[j];
      else {
        arr[j + 1] = key;
        break;
      }
    }
  }
  int prer = 0;
  int r;
  for (int i = 1; i <= n; i++) {
    r = arr[i - 1];
    for (int j = 1; j <= r; j++) {
      ans[i][j] += ans[i][j - 1] + ans[i - 1][j];
      ans[i][j] %= modd;
    }
    prer = min(r + prer, k);
    for (int j = r + 1; j <= prer; j++) {
      ans[i][j] += ans[i][j - 1] + ans[i - 1][j] - ans[i - 1][j - r - 1];
      ans[i][j] = (ans[i][j] + modd) % modd;
    }
  }
  cout << ans[n][k] << endl;
}
