output_description: Print the maximum possible value of s.
  
  * * *
input_description: Input is given from Standard Input in the following format:
  
      
      
      N
      D_1 D_2 ... D_N
attempt: import math
  
  # import sys
  # input = sys.stdin.readline
  
  
  def make_divisors(n):
      divisors = []
      for i in range(1, int(n**0.5) + 1):
          if n % i == 0:
              divisors.append(i)
              if i != n // i:
                  divisors.append(n // i)
  
      # divisors.sort()
      return divisors
  
  
  def ValueToBits(x, digit):
      res = [0 for i in range(digit)]
      now = x
      for i in range(digit):
          res[i] = now % 2
          now = now >> 1
      return res
  
  
  def BitsToValue(arr):
      n = len(arr)
      ans = 0
      for i in range(n):
          ans += arr[i] * 2**i
      return ans
  
  
  def ZipArray(a):
      aa = [[a[i], i] for i in range(n)]
  
      aa.sort(key=lambda x: x[0])
      for i in range(n):
          aa[i][0] = i + 1
      aa.sort(key=lambda x: x[1])
      b = [aa[i][0] for i in range(len(a))]
      return b
  
  
  def ValueToArray10(x, digit):
      ans = [0 for i in range(digit)]
      now = x
      for i in range(digit):
          ans[digit - i - 1] = now % 10
          now = now // 10
      return ans
  
  
  def Zeros(a, b):
      if b <= -1:
          return [0 for i in range(a)]
      else:
          return [[0 for i in range(b)] for i in range(a)]
  
  
  def AddV2(v, w):
      return [v[0] + w[0], v[1] + w[1]]
  
  
  dir4 = [[1, 0], [0, 1], [-1, 0], [0, -1]]
  
  
  def clamp(x, y, z):
      return max(y, min(z, x))
  
  
  class Bit:
      def __init__(self, n):
          self.size = n
          self.tree = [0] * (n + 1)
  
      def sum(self, i):
          s = 0
          while i > 0:
              s += self.tree[i]
              i -= i & -i
          return s
  
      def add(self, i, x):
          while i <= self.size:
              self.tree[i] += x
              i += i & -i
  
  
  #
  def Zaatsu(a):
      a.sort()
      now = a[0][0]
      od = 0
      for i in range(n):
          if now == a[i][0]:
              a[i][0] = od
          else:
              now = a[i][0]
              od += 1
              a[i][0] = od
  
      a.sort(key=lambda x: x[1])
      return a
  
  
  class UnionFind:
      def __init__(self, n):
          self.par = [i for i in range(n + 1)]
          self.rank = [0] * (n + 1)
  
      # 検索
      def find(self, x):
          if self.par[x] == x:
              return x
          else:
              self.par[x] = self.find(self.par[x])
              return self.par[x]
  
      # 併合
      def union(self, x, y):
          x = self.find(x)
          y = self.find(y)
          if self.rank[x] < self.rank[y]:
              self.par[x] = y
          else:
              self.par[y] = x
              if self.rank[x] == self.rank[y]:
                  self.rank[x] += 1
  
      # 同じ集合に属するか判定
      def same_check(self, x, y):
          return self.find(x) == self.find(y)
  
  
  """
  def cmb(n, r, p):
      if (r < 0) or (n < r):
          return 0
      r = min(r, n - r)
      return fact[n] * factinv[r] * factinv[n-r] % p
  
  p = 2
  N = 10 ** 6 + 2
  fact = [1, 1]  # fact[n] = (n! mod p)
  factinv = [1, 1]  # factinv[n] = ((n!)^(-1) mod p)
  inv = [0, 1]  # factinv 計算用
  
  for i in range(2, N + 1):
      fact.append((fact[-1] * i) % p)
      inv.append((-inv[p % i] * (p // i)) % p)
      factinv.append((factinv[-1] * inv[-1]) % p)
  
  """
  
  
  def rl(x):
      return range(len(x))
  
  
  # a = list(map(int, input().split()))
  
  #################################################
  #################################################
  #################################################
  #################################################
  
  
  # 11-
  
  n = int(input())
  
  aa = list(map(int, input().split()))
  t = [0 for i in range(13)]
  a = []
  
  for i in aa:
  
      if t[i] <= 1:
          t[i] += 1
          a.append(i)
      if t[i] == 2 or i == 0:
          print(0)
          exit()
  
  # print(a)
  n = len(a)
  
  b = [0 for i in range(25)]
  ans = 0
  count = 0
  
  for i in range(2 ** (n - 1)):
      count += 1
      for j in range(25):
          b[j] = 0
      b[0] = 1
      b[24] = 1
      for j in range(n):
          if (i >> j) & 1:
              b[24 - a[j]] += 1
          else:
              b[a[j]] += 1
      minim = 24
      prev = -24
      for j in range(0, 25):
          if b[j] == 1:
              minim = min(minim, j - prev)
              prev = j
          elif b[j] >= 2:
              minim = 0
              break
      ans = max(ans, minim)
      # print(b)
  
  print(ans)
  # print(count)
  
problem_description: Statement
  
  In CODE FESTIVAL XXXX, there are N+1 participants from all over the world,
  including Takahashi.
  
  Takahashi checked and found that the _time gap_ (defined below) between the
  local times in his city and the i-th person's city was D_i hours. The time gap
  between two cities is defined as follows. For two cities A and B, if the local
  time in city B is d o'clock at the moment when the local time in city A is 0
  o'clock, then the time gap between these two cities is defined to be
  min(d,24-d) hours. Here, we are using 24-hour notation. That is, the local
  time in the i-th person's city is either d o'clock or 24-d o'clock at the
  moment when the local time in Takahashi's city is 0 o'clock, for example.
  
  Then, for each pair of two people chosen from the N+1 people, he wrote out the
  time gap between their cities. Let the smallest time gap among them be s
  hours.
  
  Find the maximum possible value of s.
samples: [{"input": "3\n    7 12 8", "output": "4\n    \n\nFor example, consider the situation where it is 7, 12 and 16 o'clock in each\nperson's city at the moment when it is 0 o'clock in Takahashi's city. In this\ncase, the time gap between the second and third persons' cities is 4 hours.\n\n* * *"}, {"input": "2\n    11 11", "output": "2\n    \n\n* * *"}, {"input": "1\n    0", "output": "0\n    \n\nNote that Takahashi himself is also a participant."}]