N=int(input())+1
D=[0]+[int(i) for i in input().split()]
ans=12
for i in D:
  for j in D:
    x=[i,24-i]
    y=[j,24-j]
    for p in x:
      for q in y:
        if ans>min(abs(p-q),24-abs(p-q)):
          ans=min(abs(p-q),24-abs(p-q))
print(ans)
