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: from itertools import product
  import random
  
  def solve(n,dl):
      # n = int(input())
      # dl = list(map(int, input().split()))
  
      if 0 in dl:
          return 0
  
      doubles = []
      dl1 = []
      dl2 = []
      for i in range(1,13):
          i_cnt = dl.count(i)
          if i_cnt > 2:
              return 0
          elif i_cnt == 2:
              dl2.append(24-i)
              dl2.append(i)
          elif i_cnt == 1:
              dl1.append(i)        
  
      ans = 0
      ite = list(product(range(2),repeat=len(dl1)))
      for pattern in ite:
          dl24 = [0,24]
          for i, v in enumerate(pattern):
              if v == 1:
                  dl24.append(24-dl1[i])
              else:
                  dl24.append(dl1[i])
          dl24 = dl24 + dl2
          dl24.sort()
          diff_min = 24
          # print(dl24)
          if len(dl24) == 1:
              ans = max(ans, min(dl24[0], 24-dl24[0]))
          else:
              for a,b in zip(dl24[:-1],dl24[1:]):
                  diff = b-a
                  if diff != 24
                      diff_min = min(diff_min,diff)
              ans = max(diff_min,ans)
      return ans
  
  
  def solve2(n,dl):
      ite = list(product(range(2),repeat=len(dl)))
      ans = 0
      for pattern in ite:
          dl_new = [0]
          for i, v in enumerate(pattern):
              if v == 1:
                  dl_new.append(24-dl[i])
              else:
                  dl_new.append(dl[i])
          dl_new.sort()
          diff_min = 24
          for a,b in zip(dl_new[:-1], dl_new[1:]):
              diff = b-a
              diff_min = min(diff_min, diff)
          ans = max(ans,diff_min)
      return ans
  
  
  if __name__ == "__main__":
      n = int(input())
      dl = list(map(int, input().split()))
      ans = solve(n,dl)
      print(ans)
      # for _ in range(10):
      #     n = random.randint(1,10)
      #     dl = [random.randint(1,12) for _ in range(n)]
      #     ans1 = solve(n, dl[:])
          # ans2 = solve2(n,dl[:])
          # if ans1 != ans2:
          #     print(n)
          #     print(dl)
          #     print(ans1)
          #     print(ans2)
          #     print('----')
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."}]