#include <bits/stdc++.h>
using namespace std;
int n, k, a[105];
long long dp[100005][105];
const long long mod = (long long)1e9 + 7;
long long rek(int x, long long sum, long long dosad) {
  if (!sum) return 1;
  long long &ret = dp[sum][x];
  if (ret != -1) return ret;
  ret = 0;
  if (dosad < a[x]) ret = rek(x, sum - 1, dosad + 1);
  if (x < n - 1) {
    ret = (ret + rek(x + 1, sum, 1)) % mod;
  }
  return ret;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> k;
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
  }
  memset(dp, -1, sizeof(dp));
  cout << rek(0, k, 0) << endl;
  return 0;
}
