atcoder#ARC128E. [ARC128E] K Different Values

[ARC128E] K Different Values

Score : 800800 points

Problem Statement

Given are a sequence of NN integers A=(A1,A2,,AN)A=(A_1,A_2,\cdots,A_N) and an integer KK.

Consider making a sequence of integers xx that satisfies both of the following conditions.

  • For each integer ii (1iN1 \leq i \leq N), xx contains exactly AiA_i occurrences of ii. xx does not contain other integers.
  • For every way of choosing KK consecutive elements from xx, their values are all distinct.

Determine whether it is possible to make xx that satisfies the conditions. If it is possible, find the lexicographically smallest such xx.

Constraints

  • 2KN5002 \leq K \leq N \leq 500
  • 1Ai1 \leq A_i
  • 1iNAi200000\sum_{1 \leq i \leq N} A_i \leq 200000
  • All values in input are integers.

Input

Input is given from Standard Input in the following format:

NN KK

A1A_1 A2A_2 \cdots ANA_N

Output

If it is impossible to make a sequence xx that satisfies the conditions, print -1. If it is possible, print the lexicographically smallest such xx.

3 3
2 2 1
1 2 3 1 2

Two sequences x=(1,2,3,1,2),(2,1,3,2,1)x=(1,2,3,1,2),(2,1,3,2,1) satisfy the conditions. The lexicographically smaller one, (1,2,3,1,2)(1,2,3,1,2), is the answer.

3 2
2 1 2
1 2 3 1 3
3 3
1 3 3
-1