program time_gap
  implicit none
  integer :: n, d(50), t(0:12), x, y(11), u, m, s, i, j, k
  logical :: c(0:24), f(0:24)
  d = 0
  t = 0
  y = 0
  c = .false.
  t(0) = 1
  read(*,*) n
  read(*,*) d(1:n)
  do i = 1, n
    t(d(i)) = t(d(i))+1
  end do
  if (t(0).gt.1.or.t(12).gt.1) then
    write(*,'(i0)') 0
    stop
  end if
  x = 0
  c(0) = .true.
  c(24) = .true.
  do i = 1, 11
    if (t(i).gt.2) then
      write(*,'(i0)') 0
      stop
    else if (t(i).eq.2) then
      c(i) = .true.
      c(24-i) = .true.
    else if (t(i).eq.1) then
      x = x+1
      y(x) = i
    end if
  end do
  if (t(12).eq.1) c(12) = .true.
  u = 2**x-1
  m = 0
  do k = 0, u
    f = c
    do i = 1, x
      if (btest(k,i-1)) then
        f(y(i)) = .true.
      else
        f(24-y(i)) = .true.
      end if
    end do
    s = 24
    i = 0
    do
      j = i+1
      do while (.not.f(j))
        j = j+1
      end do
      s = min(s,j-i)
      if (j.eq.24) exit
      i = j
    end do
    m = max(m,s)
  end do
  write(*,'(i0)') m
  stop
end program time_gap