from collections import Counter
import itertools

N = int(input())
Ds = list(map(int, input().split())) + [0]

cnt = Counter(Ds)

if max(cnt.values()) >= 3:
    print(0)
    exit()

citys = []
rest = []
for k, v in cnt.items():
    if v == 2:
        if k == 0 or k == 12:
            print(0)
            exit()
        citys.append(k)
        citys.append(24 -k)
    else:
        rest.append(k)


def check(citys):
    if len(citys) <= 1:
        return 24

    citys.sort()

    ans = 24
    prev = citys[-1] - 24
    for c in citys:
        ans = min(ans, c - prev)
        prev = c

    return ans


if check(citys) == 1:
    print(1)
    exit()

ans = 0
for ops in itertools.product('+-', repeat=len(rest)):
    citys2 = citys.copy()
    for i in range(len(rest)):
        if ops[i] == '+':
            citys2.append(rest[i])
        else:
            citys2.append(24 - rest[i])

    ans = max(ans, check(citys2))

print(ans)
