#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9 + 7;
const int MAX = 1e5 + 5;
const double PI = acos(-1.0);
const long double EPS = 1e-10;
const int64_t INF = 1e18 + 10;
template <typename t>
t lcm(t a, t b) {
  return (a * b) / __gcd(a, b);
}
template <typename t>
t gcd(t a, t b) {
  return __gcd(a, b);
}
template <typename t>
t mul_mod(t a, t b, t m) {
  t res = ((a % m) * (b % m) % m);
  return res;
}
template <typename t>
t add_mod(t a, t b, t m) {
  t res = ((a % m) + (b % m)) % m;
  return res;
}
template <typename t>
t pow_mod(t a, t b, t m) {
  t res = 1;
  while (b) {
    if (b & 1) res = mul_mod(res, a, m);
    a = mul_mod(a, a, m), b >>= 1;
  }
  return res % m;
}
template <typename t>
vector<t> num_vec(t num) {
  t res;
  while (num) res.push_back(num % 10), num /= 10;
  return res;
}
template <typename t>
t vec_num(t vec) {
  t res = 0;
  long long mul = 1;
  for (long long i = 0; i < (int)vec.size(); i++) res = vec[i] * mul, mul *= 10;
  return res;
}
int32_t main(int argc, char** argv) {
  ios_base::sync_with_stdio(false);
  cin.tie(0), cout.tie(0);
  auto tstart = clock();
  int n, k;
  cin >> n >> k;
  vector<long long> a(n);
  for (long long i = 0; i < n; i++) cin >> a[i];
  vector<vector<long long> > dp(n + 1, vector<long long>(k + 1, 0)),
      pre(n + 1, vector<long long>(k + 1, 0));
  dp[0][0] = 1;
  pre[0][0] = dp[0][0];
  for (long long j = 1; j < k + 1; j++)
    pre[0][j] = pre[0][j - 1] + dp[0][j], dp[0][j] = pre[0][j];
  for (long long i = 1; i < n + 1; i++) {
    for (long long j = 0; j < k + 1; j++) {
      dp[i][j] = dp[i][j] + pre[i - 1][j] -
                 ((j > a[i - 1]) ? pre[i - 1][j - a[i - 1] - 1] : 0);
      pre[i][j] = ((j) ? pre[i][j - 1] : 0) + dp[i][j];
    }
  }
  cout << dp[n][k] << endl;
  cerr << setprecision(2) << fixed
       << "Time elapsed: " << (double)(clock() - tstart) / CLOCKS_PER_SEC
       << endl;
  return 0;
}
