#include <bits/stdc++.h>
using namespace std;
int main() {
  long n, k, j, i, f;
  cin >> n >> k;
  long a[n + 1];
  cin >> a[1];
  for (i = 2; i <= n; ++i) {
    cin >> a[i];
    a[i] = a[i] + a[i - 1];
  }
  if (a[n] < k) {
    cout << 0;
    return 0;
  }
  if (a[n] == k) {
    cout << 1;
    return 0;
  }
  long dp[n + 1][k + 1];
  dp[1][0] = 1;
  for (i = 1; i <= a[1]; ++i) dp[1][i] = (1 + dp[1][i - 1]) % 1000000007;
  while (i <= k) {
    dp[1][i] = dp[1][i - 1];
    ++i;
  }
  for (i = 2; i <= n; ++i) {
    dp[i][0] = 1;
    long v = a[i] - a[i - 1];
    long m = min(a[i], k);
    for (j = 1; j <= m; ++j) {
      long indx = max(j - j, j - v - 1);
      if (j - v - 1 >= 0)
        dp[i][j] =
            (dp[i][j - 1] + (dp[i - 1][j] - dp[i - 1][indx]) % 1000000007) %
            1000000007;
      else
        dp[i][j] = (dp[i][j - 1] + dp[i - 1][j]) % 1000000007;
    }
    while (j <= k) {
      dp[i][j] = dp[i][j - 1];
      ++j;
    }
  }
  i = k - 1;
  while (dp[n][i] == dp[n][k] && i >= 0) --i;
  if (i >= 0)
    cout << ((dp[n][k] - dp[n][i]) % 1000000007);
  else
    cout << dp[n][k];
}
