#include <bits/stdc++.h>
using namespace std;
long long n, k;
long long niz[105];
long long dp[105][100005];
long long ps[100005];
long long br;
long long pom;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cin >> n >> k;
  for (int i = 0; i < n; i++) {
    cin >> niz[i];
  }
  niz[n] = 3;
  ps[k + 1] = 1;
  ps[max(pom, k - niz[0])] = -1;
  for (int i = 0; i < n; i++) {
    br = 0;
    for (int j = k + 1; j >= 0; j--) {
      dp[i][j] = br;
      br += ps[j];
    }
    for (int j = k + 1; j >= 0; j--) {
      ps[j] = 0;
    }
    for (int j = k; j >= 0; j--) {
      ps[j + 1] += dp[i][j];
      ps[max(pom, j - niz[i + 1])] += -dp[i][j];
    }
  }
  cout << dp[n - 1][0];
  return 0;
}
