#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 10;
int a[N], b[N], id[N], ans[N];
int sum[4 * N], num[4 * N];
int n, m;
int getid(int x) { return lower_bound(b + 1, b + 1 + n, x) - b; }
int qu(int id, int l, int r, int ql, int qr, int ty) {
  if (ql <= l && r <= qr) {
    if (ty == 1)
      return sum[id];
    else
      return num[id];
  }
  int mid = l + r >> 1;
  int ans = 0;
  if (ql <= mid) ans += qu(id << 1, l, mid, ql, qr, ty);
  if (qr > mid) ans += qu(id << 1 | 1, mid + 1, r, ql, qr, ty);
  return ans;
}
void up(int id, int l, int r, int pos, int val) {
  if (l == r) {
    num[id]++;
    sum[id] += val;
    return;
  }
  int mid = l + r >> 1;
  if (pos <= mid)
    up(id << 1, l, mid, pos, val);
  else
    up(id << 1 | 1, mid + 1, r, pos, val);
  sum[id] = sum[id << 1] + sum[id << 1 | 1];
  num[id] = num[id << 1] + num[id << 1 | 1];
}
int main() {
  cin >> n >> m;
  for (int i = 1; i <= (n); ++i) {
    cin >> a[i];
    b[i] = a[i];
  }
  sort(b + 1, b + 1 + n);
  for (int i = 1; i <= (n); ++i) id[i] = getid(a[i]);
  int ss = 0;
  for (int i = 1; i <= (n); ++i) {
    if (ss + a[i] > m) {
      int l = 1, r = n;
      int id1 = -1;
      int tt = 0;
      int t1 = 0, t2 = 0;
      while (l <= r) {
        int mid = l + r >> 1;
        int qunum = qu(1, 1, n, mid, n, 1);
        if (ss - qunum + a[i] <= m) {
          l = mid + 1;
          tt = qunum;
          id1 = mid;
        } else
          r = mid - 1;
      }
      t2 = qu(1, 1, n, id1, n, 2);
      int j = b[id1];
      t1 = ceil(1.0 * ((ss - tt + a[i]) - m) / j);
      ans[i] = t1 + t2;
    }
    up(1, 1, n, id[i], a[i]);
    ss += a[i];
  }
  for (int i = 1; i <= (n); ++i) printf("%d ", ans[i]);
}
