import sys
input = sys.stdin.readline
n = int(input())
D = list(map(int,input().split()))
A = [0] * (n+1)
ans0 = 0
for i in range(n**2):
    ib = format(i, "b").zfill(n)
    for j in range(n):
        A[j] = D[j] * (-1) ** int(ib[j])
    ans = 30
    for j in range(n+1):
        for k in range(j+1, n+1):
            di = abs(A[k] - A[j])
            ans = min(ans, min(di, 24-di))
    ans0 = max(ans0, ans)
print(ans0)