import java.io.BufferedReader
import java.io.InputStream
import java.io.InputStreamReader
import java.util.*

fun main(args: Array<String>) {
    val sc = FastScanner(System.`in`)

    val n = sc.nextInt()

    val d = Array(n) { sc.nextInt() }

    val clock = mutableSetOf<Int>()
    clock.add(0)
    val unp = mutableListOf<Int>()
    for (x in d) {
        if (x == 0) {
            println(0)
            return
        }

        val count = d.filter { it == x }.count()

        if (x == 12) {
            if (count >= 2) {
                println(0)
                return
            }
            else {
                clock.add(12)
                continue
            }
        }
        when {
            count == 3 -> {
                println(0)
                return
            }
            count == 2 -> {
                clock.add(x)
                clock.add(24 - x)
            }
            count == 1 -> {
                unp.add(x)
            }
        }
    }


    var best = 0
    val s = 1 shl unp.size
    set@
    for (x in 0 until s) {
        val nClock = mutableListOf<Int>()
        nClock.addAll(clock)
        for (k in 0 until unp.size) {
            val y = if (x shr k and 1 == 1) {
                unp[k]
            }
            else {
                24 - unp[k]
            }
            nClock.add(y)
        }
        best = Math.max(best, solve(nClock))
    }

    println(best)

}

fun solve(nClock: List<Int>): Int {
    var min = 24
    for (i in 0 until nClock.size) {
        for (j in i + 1 until nClock.size){
            val y = Math.abs(nClock[i]- nClock[j])
            val z = Math.min(y, 24 - y)
            min = Math.min(min, z)
        }
    }
    return min
}

class FastScanner(s: InputStream) {
    private var st = StringTokenizer("")
    private val br = BufferedReader(InputStreamReader(s))

    fun next(): String {
        while (!st.hasMoreTokens()) st = StringTokenizer(br.readLine())

        return st.nextToken()
    }

    fun nextInt() = next().toInt()
    fun nextLong() = next().toLong()
    fun nextLine() = br.readLine()
    fun nextDouble() = next().toDouble()
    fun ready() = br.ready()
}