from collections import Counter
from itertools import product, combinations


def solve(n, ds):
    if n >= 24:
        return 0
    freq = Counter(ds)
    if 0 in freq or freq[12] >= 2 or max(freq.values()) >= 3:
        return 0
    cmp = set()
    alt = []
    for d, l in freq.items():
        if l == 2 or d == 12:
            cmp.add(d)
            cmp.add(24 - d)
        else:
            alt.append((d, 24 - d))
    ans = 0
    for prd in product((0, 1), repeat=len(alt)):
        tmp = float('inf')
        tmp_cmp = cmp.copy()
        for i, x in zip(prd, alt):
            tmp_cmp.add(x[i])
        for x, y in combinations(tmp_cmp, 2):
            tmp = min(tmp, abs(x - y))
        ans = max(ans, tmp)
    return ans


print(solve(int(input()), list(map(int, input().split()))))
