P16597 [SYSUCPC 2025] Abacus
Description
There is a special abacus lying flat on the table with a total of $m$ vertical rods. Each vertical rod has some beads, forming a total of $n$ rows. The $i$-th row from the top contains $a_i$ beads, where $a_i$ is a positive integer not exceeding $m$. Adjacent rows on a vertical rod may not necessarily both have beads. Now, the abacus is stood upright, and all beads fall naturally. Determine the number of beads in each row after the beads have fallen. It can be proved that there are still $n$ rows after the beads fall.
The process for the first sample case is as follows:
:::align{center}

:::
Input Format
The first line contains two integers $n$ and $m(1\le n,m\le 10^4)$.
The next line contains $n$ integers $a_1,a_2,\dots,a_n$. It is guaranteed that $1\le a_i\le m$ for all $i=1,2,\dots,n$.
Output Format
The only line contains $n$ integers represent the beads in each row after the process.