#agc046e. [agc046_e]Permutation Cover

[agc046_e]Permutation Cover

Problem Statement

Given are an integer KK and integers a1,dots,aKa_1,\\dots, a_K. Determine whether a sequence PP satisfying below exists. If it exists, find the lexicographically smallest such sequence.

  • Every term in PP is an integer between 11 and KK (inclusive).
  • For each i=1,dots,Ki=1,\\dots, K, PP contains aia_i occurrences of ii.
  • For each term in PP, there is a contiguous subsequence of length KK that contains that term and is a permutation of 1,dots,K1,\\dots, K.

Constraints

  • 1leqKleq1001 \\leq K \\leq 100
  • 1leqaileq1000quad(1leqileqK)1 \\leq a_i \\leq 1000 \\quad (1\\leq i\\leq K)
  • a1+dots+aKleq1000a_1 + \\dots + a_K\\leq 1000
  • All values in input are integers.

Input

Input is given from Standard Input in the following format:

KK a1a_1 a2a_2 dots\\dots aKa_K

Output

If there is no sequence satisfying the conditions, print -1. Otherwise, print the lexicographically smallest sequence satisfying the conditions.


Sample Input 1

3
2 4 3

Sample Output 1

2 1 3 2 2 3 1 2 3 

For example, the fifth term, which is 22, is in the subsequence (2,3,1)(2, 3, 1) composed of the fifth, sixth, and seventh terms.


Sample Input 2

4
3 2 3 2

Sample Output 2

1 2 3 4 1 3 1 2 4 3 

Sample Input 3

5
3 1 4 1 5

Sample Output 3

-1