#include <bits/stdc++.h>
using namespace std;
long long permutation(long long n, long long k, long long* a) {
  if (k == 0) return 1;
  long long dp[n + 1][k + 1];
  for (long long i = 0; i <= n; ++i) {
    for (long long j = 0; j <= k; ++j) {
      if (i == 0) {
        dp[i][j] = 1;
        continue;
      }
      if (j == 0) {
        dp[i][j] = 1;
        continue;
      }
      if (j - a[i - 1] > 0)
        dp[i][j] = dp[i][j - 1] + (dp[i - 1][j] - dp[i - 1][j - a[i - 1] - 1]);
      else
        dp[i][j] = dp[i][j - 1] + dp[i - 1][j];
    }
  }
  return dp[n][k] - dp[n][k - 1];
}
int32_t main() {
  long long n, k;
  cin >> n >> k;
  long long* a = new long long[n];
  for (long long i = 0; i < n; ++i) cin >> a[i];
  cout << permutation(n, k, a) << endl;
  return 0;
}
