#P12268. The Legendary Basketball Team

    ID: 14376 Type: Default 1000ms 256MiB

The Legendary Basketball Team

The Legendary Basketball Team

In the Basketball Capital, there is a legendary basketball team named "Kun's Team". The team is composed of \(n\) talented players numbered \(1, 2, \ldots, n\). This season, they played \(m\) matches. Before each match, coach Akun holds a pre-game ceremony. During the ceremony, he selects one player as the captain and sets that player's jersey number to \(0\). In addition, for all players to the right of the captain, each player’s jersey number is \(1\) greater than the player immediately to his left. Similarly, for all players to the left of the captain, each player’s jersey number is \(1\) greater than the player immediately to his right. Note that some players may end up with the same jersey number.

For instance, if \(n=5\) and the player numbered \(3\) is chosen as the captain, then the jersey numbers assigned will be \([2, 1, 0, 1, 2]\). After \(m\) matches, coach Akun wants you to determine the maximum jersey number that each player has ever worn.

inputFormat

The first line contains two integers \(n\) and \(m\) --- the number of players and the number of matches.

Each of the following \(m\) lines contains a single integer \(p\) (where \(1 \le p \le n\)), indicating that in that match the player numbered \(p\) was selected as the captain.

outputFormat

Output a single line containing \(n\) integers separated by spaces. The \(i\)-th integer should be the maximum jersey number that the player numbered \(i\) has worn in any match.

sample

5 1
3
2 1 0 1 2