#include <bits/stdc++.h>
using namespace std;
using ll = long long;
void solve() {
  int n, m;
  cin >> n >> m;
  vector<int> ar(n);
  for (int i = 0; i < n; ++i) {
    cin >> ar[i];
  }
  vector<int> has(101, 0);
  vector<int> r(101, 0);
  int sum = 0;
  for (int i = 0; i < n; ++i) {
    42;
    int es = 0;
    int l = 100;
    sum += ar[i];
    while (l > 0 && sum > m) {
      if (has[l] == 0) {
        l--;
        continue;
      }
      int re = (sum - m + l - 1) / l;
      re = min(re, has[l]);
      sum -= re * l;
      has[l] -= re;
      r[l] += re;
      es += re;
      l--;
    }
    has[ar[i]]++;
    cout << es << ' ';
    for (int ei = 1; ei <= 100; ++ei) {
      has[ei] += r[ei];
      sum += r[ei] * ei;
      r[ei] = 0;
    }
    if (0) cout << sum << endl;
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  int tt = 1;
  while (tt--) {
    solve();
  }
  return 0;
}
