import java.util.* import kotlin.system.exitProcess fun main() { val n = readLine()!!.toInt() val a = readLine()!!.split(" ").map { it.toInt() } val ord = a.zip(0 until n - 1).sortedBy { it.first } var ans = MutableList(n - 1) { 0 } var pos = 0 val queue = LinkedList>() for (i in 2..n) { while (pos < n - 1 && ord[pos].first == i - 1) queue.add(ord[pos++]) if (queue.isEmpty()) { println("NO") exitProcess(0) } val (value, index) = queue.poll()!! ans[index] = i - value } println("YES") println(ans.joinToString("\n")) }