#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1000000007;
const long double PI = acos(-1);
const long double EPS = 0.0000000001;
const long long LINF = 1001002003004005006ll;
const int INF = 1001001001;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
int main() {
  long long n, k;
  cin >> n >> k;
  vector<long long> a(n);
  long long res = 0;
  for (long long i = 0; i < (long long)(n); i++) {
    cin >> a[i];
    res += a[i];
  }
  vector<vector<long long>> dp(n + 1, vector<long long>(k + 1, 0));
  dp[0][0] = 1;
  if (k <= res) {
    for (long long i = 0; i < (long long)(n); i++) {
      long long tar = 0;
      for (long long j = 0; j < (long long)(a[i] + 1); j++) {
        dp[i + 1][j] += dp[i][j];
        if (0 < j) dp[i + 1][j] += dp[i + 1][j - 1];
        dp[i + 1][j] %= MOD;
      }
    }
    res = dp[n][a.back()];
  } else
    res = 0;
  cout << res << endl;
}
