#include <bits/stdc++.h>
using namespace std;
const int mod1 = 1e5 + 7;
const int N = 2e5 + 100;
const int mod2 = 1e9 + 7;
const long long mod3 = 1e12 + 7;
int T, n, m;
int a[N], b[N], cnt = 0, c[N];
long long tree[N * 4], totsum[N * 4];
void push_up(int rt) {
  tree[rt] = tree[rt << 1] + tree[rt << 1 | 1];
  totsum[rt] = totsum[rt << 1] + totsum[rt << 1 | 1];
}
void update(int x, int l, int r, int rt) {
  if (l == r) {
    tree[rt]++;
    totsum[rt] += b[x];
    return;
  }
  int mid = l + r >> 1;
  if (x <= mid)
    update(x, l, mid, rt << 1);
  else
    update(x, mid + 1, r, rt << 1 | 1);
  push_up(rt);
}
int query(int l, int r, int rt, int res) {
  if (l == r) {
    return res / b[l];
  }
  long long sum = totsum[rt << 1];
  int mid = l + r >> 1;
  if (sum >= res)
    return query(l, mid, rt << 1, res);
  else
    return tree[rt << 1] + query(mid + 1, r, rt << 1 | 1, res - sum);
}
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
    b[i] = a[i];
  }
  sort(b + 1, b + n + 1);
  cnt = unique(b + 1, b + n + 1) - b - 1;
  for (int i = 1; i <= n; i++) c[i] = lower_bound(b + 1, b + cnt + 1, a[i]) - b;
  long long tot = 0;
  for (int i = 1; i <= n; i++) {
    tot += a[i];
    if (tot <= m)
      printf("0 ");
    else {
      int ans = query(1, cnt, 1, m - a[i]);
      printf("%d ", i - ans - 1);
    }
    update(c[i], 1, cnt, 1);
  }
  printf("\n");
  return 0;
}
