#include <bits/stdc++.h>
using namespace std;
const long long int LLINF = 1e18;
const int INF = 1e9;
const int MOD = 1e9 + 7;
const double EPS = 1e-10;
const double PI = acos(-1);
const int SIZE = 100005;
int N, K;
int A[101];
int dp[101][SIZE];
int rec(int indx, int k, int a) {
  if (indx >= N) return 0;
  if (k == 0) return 1;
  if (dp[indx][k] != -1) return dp[indx][k];
  int ret = 0;
  if (a + 1 <= A[indx]) {
    ret = (ret + rec(indx, k - 1, a + 1)) % MOD;
  }
  ret = (ret + rec(indx + 1, k - 1, 1)) % MOD;
  return dp[indx][k] = ret;
}
int main() {
  scanf("%d %d", &N, &K);
  for (int i = 0; i < N; i++) {
    scanf("%d", &A[i]);
  }
  memset(dp, -1, sizeof(dp));
  int ans = rec(0, K, 0);
  printf("%d\n", ans);
  return 0;
}
