#include #define For(i, a, b) for(long long i = a; i < b; i++) #define rep(i, n) For(i, 0, n) #define rFor(i, a, b) for(long long i = a; i >= b; i--) #define ALL(v) (v).begin(), (v).end() #define rALL(v) (v).rbegin(), (v).rend() using namespace std; using lint = long long; using ld = long double; int INF = 2000000000; lint LINF = 1000000000000000000; struct S { set s; vector cnt; S() { rep(i, 200010) { s.insert(i); } cnt.resize(200010, 0); } void insert(int x) { cnt[x]++; if (cnt[x] == 1) { s.erase(x); } } void erase(int x) { cnt[x]--; if (cnt[x] == 0) { s.insert(x); } } int mex() { return *s.begin(); } }; int main() { int n, m; cin >> n >> m; vector a(n); rep(i, n) { cin >> a[i]; } vector ans(n + 2); S s; int r = 1; vector in(n, false); for (int l = 0; l < n; l++) { if (!in[l]) { s.insert(a[l]); in[l] = true; } if (l > 0 && in[l - 1]) { s.erase(a[l - 1]); in[l - 1] = false; } if (l == r) { r++; } while (r < n && s.mex() < m) { if (!in[r]) { s.insert(a[r]); in[r] = true; } r++; } if (s.mex() >= m) { int mn = r - l, mx = n - l; ans[mn]++; ans[mx + 1]--; } } for (int i = 1; i <= n + 1; i++) { ans[i] += ans[i - 1]; } for (int i = 1; i <= n; i++) { cout << ans[i] << endl; } }