#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 10;
long long a[N], b[N], id[N], ans[N];
long long sum[4 * N], num[4 * N];
int n;
long long m;
int getid(long long x) { return lower_bound(b + 1, b + 1 + n, x) - b; }
long long input() {
  long long x = 0, f = 0;
  char ch = getchar();
  while (ch < '0' || ch > '9') f |= ch == '-', ch = getchar();
  while (ch >= '0' && ch <= '9') x = x * 10 + ch - '0', ch = getchar();
  return f ? -x : x;
}
long long qu(int id, int l, int r, long long val) {
  if (l == r) {
    long long flag = 0;
    if (val % b[l]) flag = 1;
    return val / b[l] + flag;
  }
  int mid = l + r >> 1;
  long long ans = 0;
  if (val > sum[id << 1 | 1]) {
    ans += num[id << 1 | 1];
    ans += qu(id << 1, l, mid, val - sum[id << 1 | 1]);
  } else
    ans += qu(id << 1 | 1, mid + 1, r, val);
  return ans;
}
void up(int id, int l, int r, int pos, long long 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() {
  n = input();
  m = input();
  for (int i = 1; i <= 4 * n; ++i) sum[i] = num[i] = 0;
  for (int i = 1; i <= (n); ++i) {
    a[i] = input();
    b[i] = a[i];
  }
  sort(b + 1, b + 1 + n);
  for (int i = 1; i <= (n); ++i) id[i] = getid(a[i]);
  long long ss = 0;
  for (int i = 1; i <= (n); ++i) {
    if (ss + a[i] > m) {
      long long val = ss + a[i] - m;
      ans[i] = qu(1, 1, n, val);
    }
    up(1, 1, n, id[i], a[i]);
    ss += a[i];
  }
  for (int i = 1; i <= (n); ++i) {
    if (i != n)
      printf("%lld ", ans[i]);
    else
      printf("%lld\n", ans[i]);
  }
}
