n = int(eval(input()))

s = list(map(int, input().split()))



cnt_memo = {}

for num in s:

    if num in cnt_memo:

        cnt_memo[num] += 1

    else:

        cnt_memo[num] = 1



kakutei = [0]

mikakutei = []

for i in cnt_memo:

    if i == 0:

        print((0))

        exit()

    elif i == 12:

        if cnt_memo[i] == 1:

            kakutei.append(12)

        else:

            print((0))

            exit()

    else:

        if cnt_memo[i] == 1:

            mikakutei.append(i)

        elif cnt_memo[i] == 2:

            kakutei.append(i)

            kakutei.append(24 - i)

        else:

            print((0))

            exit()

tmp_ans1 = 25

for num1 in kakutei:

    for num2 in kakutei:

        if num1 != num2:

            tmp_ans1 =  min(tmp_ans1, min(abs(num1 - num2), 24 -abs(num1 - num2)))



len_mikakutei = len(mikakutei)

mikakutei_pattern = 2**len_mikakutei

ans = 0

for i in range(mikakutei_pattern):

    tmp = []

    num = i

    cnt = 0

    for _ in range(len_mikakutei):

        if num % 2 == 1:

            tmp.append(mikakutei[cnt])

        else:

            tmp.append(24 - mikakutei[cnt])

        num //= 2

        cnt += 1

    tmp_ans = 25

    for num1 in tmp:

        for num2 in kakutei:

            tmp_ans = min(tmp_ans, min(abs(num1 - num2), 24 -abs(num1 - num2)))

    for num1 in tmp:

        for num2 in tmp:

            if num1 != num2:

                tmp_ans = min(tmp_ans, min(abs(num1 - num2), 24 -abs(num1 - num2)))

    tmp_ans = min(tmp_ans, tmp_ans1)

    ans = max(ans, tmp_ans)



print(ans)

    
n = int(eval(input()))

d = list(map(int, input().split()))



memo = {0: 1}

for i in range(n):

    if d[i] not in memo:

        memo[d[i]] = 1

    else:

        memo[d[i]] += 1



used = [] * n

li = []

for i in memo:

    if memo[i] >= 3:

        print((0))

        exit()

    elif memo[i] == 2:

        used.append(i)

        used.append(24 - i)

    else:

        li.append(i)



ans = 0

for bit_state in range(1 << len(li)):

    tmp = used[0:]

    for i in range(len(li)):

        if bit_state & (1 << i):

            tmp.append(li[i])

        else:

            tmp.append(24 - li[i])

    tmp = sorted(tmp)

    diff = 10 ** 18

    for i in range(1, len(tmp)):

        diff = min(diff, tmp[i] - tmp[i - 1])

    diff = min(diff, 24 - (tmp[-1] - tmp[0]))

    ans = max(ans, diff)

print(ans)
n = int(eval(input()))
s = list(map(int, input().split()))
cnt_memo = {}
for num in s:
    if num in cnt_memo:
        cnt_memo[num] += 1
    else:
        cnt_memo[num] = 1
kakutei = [0]
mikakutei = []
for i in cnt_memo:
    if i == 0:
        print((0))
        exit()
    elif i == 12:
        if cnt_memo[i] == 1:
            kakutei.append(12)
        else:
            print((0))
            exit()
    else:
        if cnt_memo[i] == 1:
            mikakutei.append(i)
        elif cnt_memo[i] == 2:
            kakutei.append(i)
            kakutei.append(24 - i)
        else:
            print((0))
            exit()
tmp_ans1 = 25
for num1 in kakutei:
    for num2 in kakutei:
        if num1 != num2:
            tmp_ans1 = min(tmp_ans1, min(abs(num1 - num2), 24 - abs(num1 - num2)))
len_mikakutei = len(mikakutei)
mikakutei_pattern = 2**len_mikakutei
ans = 0
for i in range(mikakutei_pattern):
    tmp = []
    num = i
    cnt = 0
    for _ in range(len_mikakutei):
        if num % 2 == 1:
            tmp.append(mikakutei[cnt])
        else:
            tmp.append(24 - mikakutei[cnt])
        num //= 2
        cnt += 1
    tmp_ans = 25
    for num1 in tmp:
        for num2 in kakutei:
            tmp_ans = min(tmp_ans, min(abs(num1 - num2), 24 - abs(num1 - num2)))
    for num1 in tmp:
        for num2 in tmp:
            if num1 != num2:
                tmp_ans = min(tmp_ans, min(abs(num1 - num2), 24 - abs(num1 - num2)))
    tmp_ans = min(tmp_ans, tmp_ans1)
    ans = max(ans, tmp_ans)
print(ans)

n = int(eval(input()))
d = list(map(int, input().split()))
memo = {0: 1}
for i in range(n):
    if d[i] not in memo:
        memo[d[i]] = 1
    else:
        memo[d[i]] += 1
used = [] * n
li = []
for i in memo:
    if memo[i] >= 3:
        print((0))
        exit()
    elif memo[i] == 2:
        used.append(i)
        used.append(24 - i)
    else:
        li.append(i)
ans = 0
for bit_state in range(1 << len(li)):
    tmp = used[0:]
    for i in range(len(li)):
        if bit_state & (1 << i):
            tmp.append(li[i])
        else:
            tmp.append(24 - li[i])
    tmp = sorted(tmp)
    diff = 10**18
    for i in range(1, len(tmp)):
        diff = min(diff, tmp[i] - tmp[i - 1])
    diff = min(diff, 24 - (tmp[-1] - tmp[0]))
    ans = max(ans, diff)
print(ans)

-s = list(map(int, input().split())) -cnt_memo = {} -for num in s: -    if num in cnt_memo: -        cnt_memo[num] += 1 +d = list(map(int, input().split())) +memo = {0: 1} +for i in range(n): +    if d[i] not in memo: +        memo[d[i]] = 1 -        cnt_memo[num] = 1 -kakutei = [0] -mikakutei = [] -for i in cnt_memo: -    if i == 0: +        memo[d[i]] += 1 +used = [] * n +li = [] +for i in memo: +    if memo[i] >= 3: -    elif i == 12: -        if cnt_memo[i] == 1: -            kakutei.append(12) +    elif memo[i] == 2: +        used.append(i) +        used.append(24 - i) +    else: +        li.append(i) +ans = 0 +for bit_state in range(1 << len(li)): +    tmp = used[0:] +    for i in range(len(li)): +        if bit_state & (1 << i): +            tmp.append(li[i]) -            print((0)) -            exit() -    else: -        if cnt_memo[i] == 1: -            mikakutei.append(i) -        elif cnt_memo[i] == 2: -            kakutei.append(i) -            kakutei.append(24 - i) -        else: -            print((0)) -            exit() -tmp_ans1 = 25 -for num1 in kakutei: -    for num2 in kakutei: -        if num1 != num2: -            tmp_ans1 = min(tmp_ans1, min(abs(num1 - num2), 24 - abs(num1 - num2))) -len_mikakutei = len(mikakutei) -mikakutei_pattern = 2**len_mikakutei -ans = 0 -for i in range(mikakutei_pattern): -    tmp = [] -    num = i -    cnt = 0 -    for _ in range(len_mikakutei): -        if num % 2 == 1: -            tmp.append(mikakutei[cnt]) -        else: -            tmp.append(24 - mikakutei[cnt]) -        num //= 2 -        cnt += 1 -    tmp_ans = 25 -    for num1 in tmp: -        for num2 in kakutei: -            tmp_ans = min(tmp_ans, min(abs(num1 - num2), 24 - abs(num1 - num2))) -    for num1 in tmp: -        for num2 in tmp: -            if num1 != num2: -                tmp_ans = min(tmp_ans, min(abs(num1 - num2), 24 - abs(num1 - num2))) -    tmp_ans = min(tmp_ans, tmp_ans1) -    ans = max(ans, tmp_ans) +            tmp.append(24 - li[i]) +    tmp = sorted(tmp) +    diff = 10**18 +    for i in range(1, len(tmp)): +        diff = min(diff, tmp[i] - tmp[i - 1]) +    diff = min(diff, 24 - (tmp[-1] - tmp[0])) +    ans = max(ans, diff)