시간 제한 메모리 제한 제출 정답 맞은 사람 정답 비율
1 초 1024 MB 260 65 59 37.821%

문제

화학 실험을 하던 윤이는 일렬로 나열해 놓은 $N$개의 시험관에서 재밌는 특징을 발견했다. 그 특징은 모든 이웃한 시험관 쌍에 대해, 두 시험관에 들어 있는 시약의 색깔이 서로 다르다는 점이었다. 흥미롭다고 느낀 윤이는 실험보고서에 이 사실과 함께 각 색깔별 시약의 수를 적었다. 하지만 보고서를 채점하던 조교 원이는 윤이가 색깔별 시약의 수를 제대로 적었는지 의문이 들었다. 윤이의 보고서와 일치하도록 시험관을 배열할 수 있는지 판별하는 프로그램을 작성하시오.

입력

첫 번째 줄에 시험관의 개수 $N$과 색깔의 종류 수 $K$가 공백을 사이에 두고 주어진다.

두 번째 줄에 $K$개의 양의 정수 $c_i$가 공백을 사이에 두고 주어진다. 각 색깔에는 번호가 붙어 있으며, $c_i$는 $i$번 색깔의 시약이 담긴 시험관의 개수이다. $(1≤i≤K)$

출력

조건을 만족하는 시험관 배열을 만들 수 있으면, 시험관의 색깔 번호를 공백으로 구분하여 순서대로 출력한다. 답이 여러 개이면 아무 거나 출력한다.

조건을 만족하는 시험관 배열을 만들 수 없으면 $-1$을 출력한다.

제한

$1 ≤ K ≤ N ≤ 300,000$

$c_1, \cdots, c_k > 0$

$c_1+\cdots+c_k = N$

서브태스크 1 (40점)

$i≥2$에 대해 $c_i=1$

서브태스크 2 (60점)

추가적인 제약 조건이 없다.

예제 입력 1

6 3
3 1 2

예제 출력 1

1 2 3 1 3 1

이 입력은 서브태스크 1의 조건을 만족하지 않는다.

예제 입력 2

6 3
4 1 1

예제 출력 2

-1
W3sicHJvYmxlbV9pZCI6IjIwMzExIiwicHJvYmxlbV9sYW5nIjoiMCIsInRpdGxlIjoiXHVkNjU0XHVkNTU5IFx1YzJlNFx1ZDVkOCIsImRlc2NyaXB0aW9uIjoiPHA+XHVkNjU0XHVkNTU5IFx1YzJlNFx1ZDVkOFx1Yzc0NCBcdWQ1NThcdWI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