#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("-ffloat-store")
#pragma GCC optimize("-fno-defer-pop")
long long int power(long long int a, long long int b, long long int m) {
  if (b == 0) return 1;
  if (b == 1) return a % m;
  long long int t = power(a, b / 2, m) % m;
  t = (t * t) % m;
  if (b & 1) t = ((t % m) * (a % m)) % m;
  return t;
}
long long int modInverse(long long int a, long long int m) {
  return power(a, m - 2, m);
}
long long int n, k, ar[101];
long long int dp[101][100005];
long long int maxval(long long int i, long long int left) {
  if (left == 0) return 1;
  if (i == n + 1) {
    if (left == 0)
      return 1;
    else
      return 0;
  }
  if (dp[i][left] != -1) {
    return dp[i][left];
  }
  if (ar[i] <= 0) {
    return dp[i][left] = maxval(i + 1, left) % 1000000007;
  } else {
    long long int a, b;
    a = maxval(i + 1, left) % 1000000007;
    ar[i] -= 1;
    b = maxval(i, left - 1) % 1000000007;
    ar[i] += 1;
    return dp[i][left] = (a + b) % 1000000007;
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long int i, j, l;
  cin >> n >> k;
  memset(dp, -1, sizeof(dp));
  for (i = 1; i <= n; i++) {
    cin >> ar[i];
  }
  l = maxval(1, k);
  cout << l;
  return 0;
}
