#include <bits/stdc++.h>
using namespace std;
using ll = std::int_fast64_t;
using P = pair<ll, ll>;
constexpr ll inf = 1000000000;
constexpr ll mod = 1000000007;
constexpr long double eps = 1e-15;
template <typename T1, typename T2>
ostream& operator<<(ostream& os, pair<T1, T2> p) {
  os << to_string(p.first) << " " << to_string(p.second);
  return os;
}
template <typename T>
ostream& operator<<(ostream& os, vector<T>& v) {
  for (int i = 0; i < (int)v.size(); i++) {
    if (i) os << " ";
    os << to_string(v[i]);
  }
  return os;
}
struct modint {
  ll n;

 public:
  modint(const ll n = 0) : n((n % mod + mod) % mod) {}
  static modint pow(modint a, ll m) {
    modint r = 1;
    while (m > 0) {
      if (m & 1) {
        r *= a;
      }
      a = (a * a);
      m /= 2;
    }
    return r;
  }
  modint& operator++() {
    *this += 1;
    return *this;
  }
  modint& operator--() {
    *this -= 1;
    return *this;
  }
  modint operator++(int) {
    modint ret = *this;
    *this += 1;
    return ret;
  }
  modint operator--(int) {
    modint ret = *this;
    *this -= 1;
    return ret;
  }
  modint operator~() const { return (this->pow(n, mod - 2)); }
  friend bool operator==(const modint& lhs, const modint& rhs) {
    return lhs.n == rhs.n;
  }
  friend bool operator<(const modint& lhs, const modint& rhs) {
    return lhs.n < rhs.n;
  }
  friend bool operator>(const modint& lhs, const modint& rhs) {
    return lhs.n > rhs.n;
  }
  friend modint& operator+=(modint& lhs, const modint& rhs) {
    lhs.n += rhs.n;
    if (lhs.n >= mod) lhs.n -= mod;
    return lhs;
  }
  friend modint& operator-=(modint& lhs, const modint& rhs) {
    lhs.n -= rhs.n;
    if (lhs.n < 0) lhs.n += mod;
    return lhs;
  }
  friend modint& operator*=(modint& lhs, const modint& rhs) {
    lhs.n = (lhs.n * rhs.n) % mod;
    return lhs;
  }
  friend modint& operator/=(modint& lhs, const modint& rhs) {
    lhs.n = (lhs.n * (~rhs).n) % mod;
    return lhs;
  }
  friend modint operator+(const modint& lhs, const modint& rhs) {
    return modint(lhs.n + rhs.n);
  }
  friend modint operator-(const modint& lhs, const modint& rhs) {
    return modint(lhs.n - rhs.n);
  }
  friend modint operator*(const modint& lhs, const modint& rhs) {
    return modint(lhs.n * rhs.n);
  }
  friend modint operator/(const modint& lhs, const modint& rhs) {
    return modint(lhs.n * (~rhs).n);
  }
};
istream& operator>>(istream& is, modint m) {
  is >> m.n;
  return is;
}
ostream& operator<<(ostream& os, modint m) {
  os << m.n;
  return os;
}
struct binomial_coefficient {
 private:
  int m;
  vector<modint> fact;

 public:
  binomial_coefficient(int m) : m(m) {
    fact.resize(m);
    fact[0] = 1;
    for (int i = 1; i < m; i++) fact[i] = fact[i - 1] * i;
  }
  modint comb(int n, int k) {
    if (n < 0 || k < 0 || n < k) return 0;
    return fact[n] / fact[n - k] / fact[k];
  }
};
using mi = modint;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n, m;
  cin >> n >> m;
  vector<int> t(n);
  for (int i = 0; i < (int)n; i++) cin >> t[i];
  vector<int> ans(n, 0);
  priority_queue<ll> q1;
  priority_queue<ll, vector<ll>, greater<ll>> q2;
  ll sum1 = 0, sum2 = 0;
  for (int i = 0; i < (int)n; i++) {
    while (sum1 + t[i] > m) {
      sum1 -= q1.top();
      sum2 += q1.top();
      q2.push(q1.top());
      q1.pop();
    }
    ans[i] = (int)q2.size();
    q2.push(t[i]);
    sum2 += t[i];
    while (!q2.empty() && sum1 < m) {
      sum2 -= q2.top();
      sum1 += q2.top();
      q1.push(q2.top());
      q2.pop();
    }
  }
  cout << ans << endl;
  return 0;
}
