import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

import itertools

N = int(input())
D = [int(x) for x in input().split()]

counter = [1] + [0] * 12
for x in D:
    counter[x] += 1

bl = counter[0] > 1 or counter[12] > 1 or any(x >= 3 for x in counter)
if bl:
    print(0)
    exit()

itrs = [[[0]]]
for x in range(1,12):
    if counter[x] == 0:
        itr = [[]]
    elif counter[x] == 1:
        itr = [[x],[-x]]
    else:
        itr = [[x,-x]]
    itrs.append(itr)
itrs.append([[]] if counter[12] == 0 else [[12]])

def F(arr):
    f = lambda x,y: min((x-y)%24, (y-x)%24)
    return min(f(x,y) for x,y in itertools.combinations(arr,2))

answer = 0
for p in itertools.product(*itrs):
    arr = []
    for x in p:
        arr += x
    answer = max(answer, F(arr))

print(answer)