#include <bits/stdc++.h>
using namespace std;
long long int n, m;
long long int arr[200005];
map<long long int, long long int> x;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  cin >> n >> m;
  for (int i = 0; i < n; ++i) cin >> arr[i];
  long long int l = 0, sum = 0, rem = 0, ksum = 0;
  vector<long long int> ans;
  while (l < n) {
    int cnt = 0;
    rem = 0;
    sum = ksum;
    if (sum + arr[l] > m) {
      auto it = x.rbegin();
      while (sum + arr[l] > m && it != x.rend()) {
        pair<long long int, long long int> curr = *(it);
        if ((long long int)ceil((sum + arr[l] - m) * 1.0 / curr.first) >
            curr.second) {
          rem += curr.second;
          sum -= (curr.first * curr.second);
          it++;
        } else {
          rem += (long long int)ceil((sum + arr[l] - m) * 1.0 / curr.first);
          sum -= (curr.first) *
                 ((long long int)ceil((sum + arr[l] - m) * 1.0 / curr.first));
        }
      }
    }
    ksum += arr[l];
    if (x.find(arr[l]) != x.end()) {
      pair<long long int, long long int> curr = *(x.find(arr[l]));
      x.erase(arr[l]);
      x.insert(make_pair(curr.first, curr.second + 1));
    } else
      x.insert(make_pair(arr[l], 1));
    ans.push_back(rem);
    l++;
  }
  for (auto it : ans) cout << it << " ";
  cout << endl;
  return 0;
}
