import java.math.*

fun main(args: Array<String>) {
    val cnt = IntArray(13)
    readInputLine()
    readInputLine().split(" ").forEach { cnt[it.toInt()]++ }
    cnt[0]++

    if (cnt[0] >= 2 || cnt[12] >= 2) {
        println(0)
        return
    }

    for (i in 1..11) {
        if (cnt[i] >= 3) {
            println(0)
            return
        }
    }

    var l = false

    val times = mutableListOf<Int>(24)

    for (i in 0..12) {
        when (cnt[i]) {
            1 -> {
                if (l) {
                    times.add(24 - i)
                } else {
                    times.add(i)
                }
                l = !l
            }
            2 -> {
                times.add(24 - i)
                times.add(i)
            }
        }
    }

    val timesArr = times.toIntArray()

    var ans = Int.MAX_VALUE

    for (i in timesArr.indices) {
        for (j in i + 1 until timesArr.size) {
            ans = Math.min(ans, Math.abs(timesArr[i] - timesArr[j]))
        }
    }

    println(ans)
}

fun readInputLine(): String {
    return readLine()!!
}
