fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val array = readLine()!!.split(" ").map(String::toInt).toMutableList()
    if (n != array.size) return

    (0..(n - 1)).forEach { index1 ->
        if (index1 == 0) {
            array.forEachIndexed { index, num ->
                if (index == array.size - 1) println(num.toString()) else print(num.toString() + " ")
            }
            return@forEach
        }
        (1..index1).forEach { index2 ->
            val num = index1 - index2
            if (array[num] > array[num + 1]) {
                val temp = array[num]
                array[num] = array[num + 1]
                array[num + 1] = temp
            }
        }
        array.forEachIndexed { index, num ->
            if (index == array.size - 1) println(num.toString()) else print(num.toString() + " ")
        }
    }
}
