#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k;
  cin >> n >> k;
  int arr[n + 1];
  for (int i = 1; i <= n; i++) cin >> arr[i];
  long long int dp[n + 1][k + 1];
  long long int ps[n + 1][k + 1];
  memset(dp, 0, sizeof(dp));
  memset(ps, 0, sizeof(ps));
  for (int i = 0; i <= k; i++) {
    if (i <= arr[1]) {
      dp[1][i] = 1;
    }
    ps[1][0] = 1;
    if (i > 0) ps[1][i] += dp[1][i] + ps[1][i - 1];
  }
  for (int i = 2; i <= n; i++) {
    for (int j = 0; j <= k; j++) {
      long long int ans = 0;
      if (j - arr[i] - 1 >= 0) {
        ans = ps[i - 1][j - arr[i] - 1];
      }
      dp[i][j] = ps[i - 1][j] - ans;
    }
    if (i == 1) continue;
    for (int j = 0; j <= k; j++) {
      if (j == 0) {
        ps[i][j] = dp[i][j];
        continue;
      }
      ps[i][j] += ps[i][j - 1] + dp[i][j];
    }
  }
  cout << dp[n][k];
}
