#include <bits/stdc++.h>
using namespace std;
int nxt() {
  int x;
  cin >> x;
  return x;
}
long long int nxtl() {
  long long int x;
  cin >> x;
  return x;
}
void SieveOfEratosthenes(int n, vector<int> &primes) {
  bool prime[n + 1];
  memset(prime, true, sizeof(prime));
  for (int p = 2; p * p <= n; p++) {
    if (prime[p] == true) {
      for (int i = p * p; i <= n; i += p) prime[i] = false;
    }
  }
  for (int p = 2; p <= n; p++)
    if (prime[p]) primes.push_back(p);
}
long long int max(long long int a, long long int b) {
  if (a > b) return a;
  return b;
}
long long int power(long long int x, long long int y, long long int mod) {
  long long int temp;
  if (y == 0) return 1;
  temp = power(x, y / 2, mod);
  if (y % 2 == 0)
    return (temp * temp) % mod;
  else
    return (((x * temp) % mod) * temp) % mod;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n = nxt(), m = nxt();
  map<int, int, greater<int> > m2;
  vector<int> v(n);
  generate((v).begin(), (v).end(), nxt);
  int sum = 0;
  for (int i = 0; i < n; i++) {
    int diff = m - v[i];
    if (sum <= diff) {
      cout << "0 ";
      sum += v[i];
      m2[v[i]] += 1;
      continue;
    }
    diff = sum - diff;
    int x = 0;
    int c = 0;
    for (auto it = m2.begin(); it != m2.end(); it++) {
      int diff2 = diff - x;
      int y = min(it->second, (diff2 + it->first - 1) / it->first);
      c += y;
      x += y * it->first;
      if (x >= diff) break;
    }
    cout << c << " ";
    sum += v[i];
    m2[v[i]] += 1;
  }
  cout << endl;
  return 0;
}
