#include <bits/stdc++.h>
using namespace std;
int main() {
  cin.tie(0);
  unsigned n, m;
  vector<long long> a;
  vector<long long> prefix;
  map<long long, long long, greater<long long> > time;
  cin >> n >> m;
  prefix.resize(n + 1, 0);
  a.resize(n);
  for (unsigned i = 0; i < n; cin >> a[i++])
    ;
  for (unsigned i = 0; i < n; ++i) prefix[i + 1] += prefix[i] + a[i];
  long long time_left, fail_count, d;
  for (unsigned i = 0; i < n; ++i) {
    time_left = m - prefix[i];
    fail_count = 0;
    for (auto item : time) {
      time_left = min(time_left, a[i]);
      d = min(item.second, static_cast<long long>(
                               ceil(1.0 * (a[i] - time_left) / item.first)));
      time_left += d * item.first;
      fail_count += d;
      if (!d) break;
    }
    cout << fail_count << " ";
    time[a[i]]++;
  }
}
