import java.util.Scanner

object Main {
  val in = new Scanner(System.in)

  def main(args: Array[String]): Unit = {
    val N = in.nextInt()
    val D = (0 :: (0 until N).map(_ => in.nextInt()).toList).sorted

    def check(X: Int): Boolean = {
      var min = 0
      var max = 0
      var arranged = D.map { d =>
        val right = d - max
        val left = d + min
        val ret = if (left < X && right < X) {
          d
        } else if (left < X) {
          d
        } else if (right < X) {
          -d
        } else if (right < left) {
          d
        } else {
          -d
        }
        min = math.min(min, ret)
        max = math.max(max, ret)
        ret
      }
      arranged = arranged.sorted

      (0 until (N + 1)).forall(i => {
        val x = arranged(i)
        var y = arranged((i + 1) % (N + 1))
        if (x >= 0 && y < 0) {
          y += 24
        }
        val d = math.abs(x - y)
        math.min(d, 24 - d) >= X
      })
    }

    var ans = 0
    for (i <- 12 to 0 by -1) {
      if (check(i)) {
        ans = math.max(i, ans)
      }
    }

    println(ans)
  }
}
