#include <bits/stdc++.h>
using namespace std;
long long n;
vector<long long> a;
long long dp[100][100001];
long long getans(long long curr, long long rem) {
  if (curr == n && rem == 0) return 1;
  if (curr == n) return 0;
  if (rem == 0) return 1;
  if (dp[curr][rem] != -1) return dp[curr][rem];
  long long ans = 0;
  if (a[curr] == 0) {
    ans = getans(curr + 1, rem);
  } else {
    --a[curr];
    ans = (getans(curr, rem - 1) + getans(curr + 1, rem)) % 1000000007;
  }
  dp[curr][rem] = ans;
  return ans;
}
void solve() {
  cin >> n;
  long long k;
  cin >> k;
  a.resize(n);
  for (int i = 0; i < n; i++) cin >> a[i];
  for (int i = 0; i < n; i++)
    for (int j = 0; j <= k; j++) dp[i][j] = -1;
  cout << getans(0, k) << endl;
}
int main() {
  ios_base::sync_with_stdio(false);
  ;
  cin.tie(NULL);
  long long zz;
  zz = 1;
  for (int zzz = 1; zzz <= zz; zzz++) {
    solve();
  }
  return 0;
}
