#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MOD = 1e9 + 7;
ll MIN(ll a, ll b) {
  if (a < b)
    return a;
  else
    return b;
}
int main() {
  ll n, k;
  cin >> n >> k;
  vector<ll> a(n + 1);
  a.push_back(0);
  for (ll i = 1; i <= n; i++) {
    cin >> a[i];
  }
  ll dp[n + 1][k + 1];
  for (ll i = 0; i <= n; i++) {
    for (ll j = 0; j <= k; j++) {
      dp[i][j] = 0;
    }
  }
  for (ll i = 0; i <= n; i++) {
    dp[i][0] = 1;
  }
  ll sum = 0;
  for (ll i = 1; i <= n; i++) {
    sum += a[i];
    for (ll j = 1; j <= k; j++) {
      if (a[i] > j)
        dp[i][j] = (dp[i][j - 1] % MOD + dp[i - 1][j] % MOD) % MOD;
      else {
        if ((dp[i][j - 1] % MOD) > (dp[i - 1][j] % MOD))
          dp[i][j] = dp[i][j - 1] % MOD;
        else
          dp[i][j] = dp[i - 1][j] % MOD;
      }
    }
  }
  cout << dp[n][k] << endl;
  return 0;
}
