atcoder#ARC130E. [ARC130E] Increasing Minimum

[ARC130E] Increasing Minimum

Score : 800800 points

Problem Statement

Consider doing the operation below on a sequence of NN positive integers A=(A1,A2,,AN)A = (A_1, A_2, \ldots, A_N) to obtain a sequence I=(i1,i2,,iK)I = (i_1, i_2, \ldots, i_K).

  • For each k=1,2,,Kk = 1, 2, \ldots, K in this order, do the following.- Choose an ii such that Ai=min{A1,A2,,AN}A_i = \min\{A_1, A_2, \ldots, A_N\}.
    • Let ik=ii_k = i.
    • Add 11 to AiA_i.
  • Choose an ii such that Ai=min{A1,A2,,AN}A_i = \min\{A_1, A_2, \ldots, A_N\}.
  • Let ik=ii_k = i.
  • Add 11 to AiA_i.

You are given integers NN, KK, and a sequence II.

Determine whether there exists a sequence of positive integers AA for which it is possible to obtain II from the operation. If it exists, find the lexicographically smallest such sequence.

Constraints

  • 1N,K3×1051\leq N, K\leq 3\times 10^5
  • 1ikN1\leq i_k\leq N

Input

Input is given from Standard Input in the following format:

NN KK

i1i_1 i2i_2 \ldots iKi_K

Output

If there is no sequence of positive integers AA for which it is possible to obtain II from the operation, print -1. If it exists, print the lexicographically smallest among such sequences AA, in one line, with spaces in between.

4 6
1 1 4 4 2 1
1 3 3 2

Some of the sequences for which it is possible to obtain I=(1,1,4,4,2,1)I = (1,1,4,4,2,1) from the operation are (1,3,3,2)(1, 3, 3, 2) and (2,4,5,3)(2, 4, 5, 3). The lexicographically smallest among them is (1,3,3,2)(1, 3, 3, 2).

4 6
2 2 2 2 2 2
6 1 6 6
4 6
1 1 2 2 3 3
-1