#include <bits/stdc++.h>
using namespace std;
int main() {
  long long N, K;
  cin >> N >> K;
  long long arr[N];
  long long dp[N + 1][K + 1];
  long long f = K + 1;
  long long g = N + 1;
  long long presum[N + 1][K + 1];
  memset(dp, 0, sizeof(dp[0][0]) * g * f);
  memset(presum, 0, sizeof(presum[0][0]) * g * f);
  for (long long i = 0; i < N; i++) {
    cin >> arr[i];
  }
  for (long long i = 0; i <= K; i++) {
    if (arr[0] >= i) {
      dp[1][i] = 1;
    }
    if (i == 0) {
      presum[1][i] = dp[1][i];
    } else {
      presum[1][i] = presum[1][i - 1] + dp[1][i];
    }
  }
  for (long long p = 2; p <= N; p++) {
    for (long long candy = 0; candy <= K; candy++) {
      if (candy <= arr[p - 1]) {
        dp[p][candy] = dp[p][candy] + presum[p - 1][candy];
      } else {
        dp[p][candy] = dp[p][candy] + presum[p - 1][candy] -
                       presum[p - 1][candy - 1 - arr[p - 1]];
      }
      if (candy >= 1) {
        presum[p][candy] = dp[p][candy] + presum[p][candy - 1];
      } else {
        presum[p][candy] = dp[p][candy];
      }
    }
  }
  cout << dp[N][K] << endl;
}
