import java.util.*

fun main(args: Array<String>) {
    val N = readLine()!!.toInt()
    val D = readLine()!!.split(" ").map { it.toInt() }

    val d = IntArray(13) { 0 }
    d[0] = 1

    D.forEach {
        d[it]++
    }

    var res = 0

    val st = TreeSet<Int>()
    val solo = TreeSet<Int>()

    for (s in 0 until (1 shl 13)) {
        var list = ArrayList<Int>()
        list.addAll(Array(d[0]) {0})
        list.addAll(Array(d[12]) {12})

        for (i in 1..11) {
            if (d[i] == 0) continue

            if (d[i] > 1) {
                list.add(i)
                list.addAll(Array(d[i] - 1) { 24 - i })
            } else if ((s shr i) and 1 == 1) {
                list.add(i)
            } else {
                list.add(24 - i)
            }
        }
        var h = 24
        for (i in list.indices) for (j in (i + 1) until list.size) {
            val d = Math.abs(list[i] - list[j])
            h = Math.min(h, Math.min(d, 24 - d))
        }
        res = Math.max(res, h)
    }

    println(res)
}
