#include <bits/stdc++.h>
using namespace std;
int n;
int dp[101][100010];
long long solve(int index, int k, int arr[]) {
  if (index == n and k == 0) return {dp[n][0] = 1};
  if (index == n and k >= 0) return dp[n][k] = 0;
  if (k < 0) {
    return dp[index][0] = 0;
  }
  if (dp[index][k] != -1) return dp[index][k];
  long long ans = 0;
  ans = solve(index + 1, k, arr) % 1000000007;
  if (k >= 0 and arr[index] > 0) {
    arr[index]--;
    ans = (ans + solve(index, k - 1, arr)) % 1000000007;
  }
  if (k >= 0 and arr[index] > 0) {
    arr[index]--;
    ans = (ans + solve(index + 1, k - 1, arr)) % 1000000007;
  }
  return dp[index][k] = ans;
}
int main() {
  int k;
  cin >> n >> k;
  int arr[n];
  memset(dp, -1, sizeof dp);
  for (int i = 0; i < n; i++) cin >> arr[i];
  long long ans = solve(0, k, arr);
  cout << ans;
  return 0;
}
