using System; using static System.Console; using System.Linq; using System.Collections.Generic; class Program { static int NN => int.Parse(ReadLine()); static int[] NList => ReadLine().Split().Select(int.Parse).ToArray(); public static void Main() { Solve(); } static void Solve() { var c = NList; var (n, m) = (c[0], c[1]); var a = NList; if (m == 0) { var ans2 = new int[n]; for (var i = 0; i < n; ++i) ans2[i] = n - i; WriteLine(string.Join("\n", ans2)); return; } var INF = int.MaxValue / 2; var pos = Enumerable.Repeat(INF, m).ToArray(); var next = new int[n]; for (var i = n - 1; i >= 0; --i) if (a[i] < m) { next[i] = pos[a[i]]; pos[a[i]] = i; } var seg = new SegmentTree(pos, new SegOp()); var cum = new int[n + 1]; for (var i = 0; i < n; ++i) { var left = seg.Prod(0, m) - i; var right = n - i; if (left < n) ++cum[left]; if (left <= right && right <= n) --cum[right]; if (a[i] < m) seg[a[i]] = next[i]; } var ans = new int[n]; for (var i = 0; i < n; ++i) { if (i > 0) cum[i] += cum[i - 1]; ans[i] = cum[i]; } WriteLine(string.Join("\n", ans)); } struct SegOp : ISegmentTreeOperator { public int Identity => 0; public int Operate(int x, int y) { return Math.Max(x, y); } } interface ISegmentTreeOperator { T Identity { get; } T Operate(T x, T y); } class SegmentTree { int _n; int size; int log; T[] d; ISegmentTreeOperator op; void Update(int k) { d[k] = op.Operate(d[2 * k], d[2 * k + 1]); } public SegmentTree(int n, ISegmentTreeOperator op) { this.op = op; _n = n; size = 1; while (size < n) size <<= 1; log = CountRZero(size); d = new T[2 * size]; for (var i = 0; i < d.Length; ++i) d[i] = op.Identity; } public SegmentTree(T[] v, ISegmentTreeOperator op) { this.op = op; _n = v.Length; size = 1; while (size < v.Length) size <<= 1; log = CountRZero(size); d = new T[2 * size]; for (var i = 0; i < size; ++i) d[i] = op.Identity; for (var i = 0; i < v.Length; ++i) d[size + i] = v[i]; for (var i = size - 1; i >= 1; --i) Update(i); } int CountRZero(int n) { var ans = 0; while (n % 2 == 0) { ++ans; n >>= 1; } return ans; } public T this[int p] { get { return d[p + size]; } set { p += size; d[p] = value; for (var i = 1; i <= log; ++i) Update(p >> i); } } public T Prod(int l, int r) { var sml = op.Identity; var smr = op.Identity; l += size; r += size; while (l < r) { if ((l & 1) != 0) sml = op.Operate(sml, d[l++]); if ((r & 1) != 0) smr = op.Operate(d[--r], smr); l >>= 1; r >>= 1; } return op.Operate(sml, smr); } T AllProd() => d[1]; int MinLeft(int r, Predicate f) { if (r == 0) return 0; r += size; T sm = op.Identity; do { r--; while (r > 1 && (r % 2) != 0) r >>= 1; if (!f(op.Operate(d[r], sm))) { while (r < size) { r = 2 * r + 1; if (f(op.Operate(d[r], sm))) { sm = op.Operate(d[r], sm); r--; } } return r + 1 - size; } sm = op.Operate(d[r], sm); } while ((r & -r) != r); return 0; } public int MaxRight(int l, Predicate f) { if (l == _n) return _n; l += size; T sm = op.Identity; do { while (l % 2 == 0) l >>= 1; if (!f(op.Operate(sm, d[l]))) { while (l < size) { l = 2 * l; if (f(op.Operate(sm, d[l]))) { sm = op.Operate(sm, d[l]); ++l; } } return l - size; } sm = op.Operate(sm, d[l]); ++l; } while ((l & -l) != l); return _n; } } }