n = int(input())
d_l = list(map(int, input().split()))

if n == 1:
    print(0)

mn = min(d_l)
for i in range(n):
    for j in range(i+1, n):
        ans = max(abs(d_l[i]-d_l[j]), abs(24-d_l[i]-d_l[j]))
        if mn > ans: mn = ans

print(mn)
    

