N = int(input())
D = list(map(int, input().split()))
rec = [0] * 13
for i in range(N):
    rec[D[i]] += 1

if rec[0] >= 1:
    print(0)
    exit()

ans = 0
for i in range(1 << 12):
    tmp = [0]
    for j in range(13):
        if rec[j] >= 3:
            print(0)
            exit()
        elif rec[j] == 2:
            tmp.append(j)
            tmp.append(24 - j)
        elif rec[j] == 1:
            if i & 1 << j:
                tmp.append(j)
            else:
                tmp.append(24 - j)
    tmp = sorted(tmp)
    pre = tmp[0]
    num = float("inf")
    for i in range(1, len(tmp)):
        num = min(num, tmp[i] - pre)
        pre = tmp[i]

    ans = max(min(num, 24 - tmp[-1]), ans)

print(ans)
