{"problem":{"name":"K Different Values","description":{"content":"Given are a sequence of $N$ integers $A=(A_1,A_2,\\cdots,A_N)$ and an integer $K$. Consider making a sequence of integers $x$ that satisfies both of the following conditions. *   For each integer $i$ ","description_type":"Markdown"},"platform":"AtCoder","limit":{"time_limit":2000,"memory_limit":262144},"difficulty":"None","is_remote":true,"is_sync":true,"sync_url":null,"sign":"arc128_e"},"statements":[{"statement_type":"Markdown","content":"Given are a sequence of $N$ integers $A=(A_1,A_2,\\cdots,A_N)$ and an integer $K$.\nConsider making a sequence of integers $x$ that satisfies both of the following conditions.\n\n*   For each integer $i$ ($1 \\leq i \\leq N$), $x$ contains exactly $A_i$ occurrences of $i$. $x$ does not contain other integers.\n*   For every way of choosing $K$ consecutive elements from $x$, their values are all distinct.\n\nDetermine whether it is possible to make $x$ that satisfies the conditions. If it is possible, find the lexicographically smallest such $x$.\n\n## Constraints\n\n*   $2 \\leq K \\leq N \\leq 500$\n*   $1 \\leq A_i$\n*   $\\sum_{1 \\leq i \\leq N} A_i \\leq 200000$\n*   All values in input are integers.\n\n## Input\n\nInput is given from Standard Input in the following format:\n\n$N$ $K$\n$A_1$ $A_2$ $\\cdots$ $A_N$\n\n[samples]","is_translate":false,"language":"English"}],"meta":{"iden":"arc128_e","tags":[],"sample_group":[["3 3\n2 2 1","1 2 3 1 2\n\nTwo sequences $x=(1,2,3,1,2),(2,1,3,2,1)$ satisfy the conditions. The lexicographically smaller one, $(1,2,3,1,2)$, is the answer."],["3 2\n2 1 2","1 2 3 1 3"],["3 3\n1 3 3","\\-1"]],"created_at":"2026-03-03 11:01:14"}}