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

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

print(mn)
    

