from collections import Counter
N = int(input())
ds = list(map(int, input().split()))
c = Counter(ds)
cs = c.most_common()

if N >= 24 or cs[0][1] >= 3 or 0 in c:
  print("0")
  exit()

l = len(cs)
k = 0
s = (1 << 0) + (1 << 24)
while k < l and cs[k][1] == 2:
  s += (1 << cs[k][0]) + (1 << (24 - cs[k][0]))
  k += 1

def process(s, i):
  if i == l:
    return min(map(len, bin(s)[2:].split("1")[1:-1])) + 1
  return max(
    process(s + (1 << cs[i][0]), i+1),
    process(s + (1 << (24 - cs[i][0])), i+1),
  )

print(process(s, k))