N = int(input())
D = sorted(list(map(int, input().split())))

D1 = [0] + [(D[i] if i % 2 == 0 else 24 - D[i]) for i in range(N)]
D2 = [0] + [(D[i] if i % 2 == 0 else 24 - D[i]) for i in range(N)]

ans1 = float('inf')
ans2 = float('inf')

for i in range(N + 1):
    for j in range(i + 1, N + 1):
        ans1 = min(ans1, abs(D1[i] - D1[j]))
        ans2 = min(ans2, abs(D2[i] - D2[j]))

print(max(ans1, ans2))
