object Main {
  def main(args: Array[String]): Unit = {
    val s = new Main()
    s.solve()
    s.out.flush()
  }
}

class Main {
  import java.io._
  import java.util.StringTokenizer

  import scala.collection.mutable
  import scala.util.Sorting
  import math.{abs, max, min}
  import mutable.{ArrayBuffer, ListBuffer}
  import scala.reflect.ClassTag

  val MOD = 1000000007
  val out = new PrintWriter(System.out)

  def solve(): Unit = {
    val N = ni()
    val D = Array.ofDim[Int](13)
    rep(N) { _ =>
      D(ni()) += 1
    }

    val dup = D.zipWithIndex exists {
      case (num, i) => i match {
        case 0 => num >= 1
        case 12 => num >= 2
        case _ => num >= 3
      }
    }
    if (dup) out.println(0)
    else {
      var ans = 0

      def minContinuousZero(bit: Int, K: Int): Int = {
        def step(k: Int, cnt: Int, ms: Int): Int = {
          k match {
            case K => if (cnt > 0) min(cnt, ms) else ms
            case _ =>
              if ((bit & 1 << k) == 0) {
                step(k + 1, if (cnt > 0) cnt + 1 else 1, ms) // 0
              } else {
                step(k + 1, -1, if (cnt > 0) min(cnt, ms) else ms) // 1
              }
          }
        }

        val ms = step(0, -1, K + 1)
        if (ms == K + 1) 0 else ms
      }

      def calcMin(times: Int): Int = {
        // 高橋くんがいるので0時をまたぐケースは考えなくていい
        minContinuousZero(times, 24) + 1
      }

      rep(math.pow(2, 12).toInt - 1) { i =>
        var times = 1 // 高橋くんのぶん
        if (D(12) == 1) times |= 1 << 12
        rep(11, 1) { d =>
          if (D(d) == 2) {
            times |= 1 << d
            times |= 1 << 24 - d
          }
        }

        rep(11) { k =>
          if (D(k + 1) == 1) {
            // onのときは24-d, d = k + 1
            if ((i & 1 << k) > 0) {
              times |= 1 << 24 - (k + 1)
            } else {
              times |= 1 << k + 1
            }
          }
        }

        ans = max(ans, calcMin(times))
      }

      out.println(ans)
    }
  }


  class InputReader(val stream: InputStream) {
    private val reader = new BufferedReader(new InputStreamReader(stream), 32768)
    private var tokenizer: StringTokenizer = _

    def next(): String = {
      while (tokenizer == null || !tokenizer.hasMoreTokens)
        tokenizer = new StringTokenizer(reader.readLine)
      tokenizer.nextToken
    }

    def nextInt(): Int = next().toInt
    def nextLong(): Long = next().toLong
    def nextChar(): Char = next().charAt(0)
  }
  val sc = new InputReader(System.in)
  def ni(): Int = sc.nextInt()
  def nl(): Long = sc.nextLong()
  def nc(): Char = sc.nextChar()
  def ns(): String = sc.next()
  def ns(n: Int): Array[Char] = ns().toCharArray
  def na(n: Int): Array[Int] = map(n)(_ => ni())
  def nal(n: Int): Array[Long] = map(n)(_ => nl())
  def nm(n: Int, m: Int): Array[Array[Char]] = map(n) (_ => ns(m))
  def rep(n: Int, offset: Int = 0)(f: Int => Unit): Unit = {
    var i = offset
    val N = n + offset
    while(i < N) { f(i); i += 1 }
  }
  def rep_r(n: Int, offset: Int = 0)(f: Int => Unit): Unit = {
    var i = n - 1 + offset
    while(i >= offset) { f(i); i -= 1 }
  }

  def map[@specialized A: ClassTag](n: Int)(f: Int => A): Array[A] = {
    val res = Array.ofDim[A](n)
    rep(n)(i => res(i) = f(i))
    res
  }

  def sumL(as: Array[Int]): Long = {
    var s = 0L
    rep(as.length)(i => s += as(i))
    s
  }
}
