atcoder#ARC125C. [ARC125C] LIS to Original Sequence

[ARC125C] LIS to Original Sequence

Score : 600600 points

Problem Statement

Given are an integer NN and a monotonically increasing sequence of KK integers A=(A1,A2,,AK)A=(A_1,A_2,\cdots,A_K). Find the lexicographically smallest permutation PP of (1,2,,N)(1,2,\cdots,N) that satisfies the following condition.

  • AA is a longest increasing subsequence of PP (a monotonically increasing subsequence of PP with the maximum possible length). It is fine if PP has multiple longest increasing subsequences, one of which is AA.

From the Constraints of this problem, we can prove that there always exists a PP that satisfies the condition.

Constraints

  • 1KN2×1051 \leq K \leq N \leq 2 \times 10^5
  • 1A1<A2<<AKN1 \leq A_1 < A_2 < \cdots < A_K \leq N
  • All values in input are integers.

Input

Input is given from Standard Input in the following format:

NN KK

A1A_1 A2A_2 \cdots AKA_K

Output

Print the answer.

3 2
2 3
2 1 3

AA is a longest increasing subsequence of PP when P=(2,1,3),(2,3,1)P=(2,1,3),(2,3,1). The answer is the lexicographically smallest of the two, or (2,1,3)(2,1,3).

5 1
4
5 4 3 2 1