fun Int.bit(i: Int) = 1 shl i and this > 0

fun main(A: Array<String>) {
    val n = readLine()!!.toInt()
    if (n > 24) {
        println(0)
        return
    }

    val a = readLine()!!.split(" ").map { it.toInt() }
    val b = java.util.BitSet(25)
    b[0] = true
    b[24] = true

    (0 until (1 shl n)).asSequence().map { bit ->
        b.clear(1, 24)
        for (i in a.indices) {
            val j = if (bit.bit(i)) 24 - a[i] else a[i]
            if (b[j])
                return@map 0
            b[j] = true
        }

        (1..24).asSequence().filter { b.get(it) }
                .map { it - b.previousSetBit(it - 1) }
                .min() ?: 0
    }.max().let(::println)
}
