import numpy as np



N = int(eval(input()))

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

if N > 23:

    print((0))

    exit()

if D.count(0) >= 2:

    print((0))

    exit()

for i in range(1, 13):

    if D.count(i) >= 3:

        print((0))

        exit()

for i in range(13):

    if (D.count(i) + D.count(i+1)) == 4:

        print((1))

        exit()



# 深さ優先探索で全通りを探索できるのでは curは０からスタート

def dfs(cur, times):

    global answer

    if cur == N:

        times.sort()

        arr = np.array(times)

        result = (arr[1:] - arr[:-1]).min()

        if result > answer:

            answer = result

    else:

        x = D[cur]

        dfs(cur+1, times + [x])

        dfs(cur+1, times + [24-x])



answer = 0

dfs(0, [0, 24])

print(answer)

N = int(eval(input())) + 1

D = list(map(int, input().split())) + [0] + [24]

D.sort()

for i in range(1, N, 2):

    D[i] = 24 - D[i]

D.sort()

ans = 24

for i in range(N):

    ans = min(ans, abs(D[i+1]-D[i]))

print(ans)

import numpy as np

N = int(eval(input()))
D = list(map(int, input().split()))
if N > 23:
    print((0))
    exit()
if D.count(0) >= 2:
    print((0))
    exit()
for i in range(1, 13):
    if D.count(i) >= 3:
        print((0))
        exit()
for i in range(13):
    if (D.count(i) + D.count(i + 1)) == 4:
        print((1))
        exit()
# 深さ優先探索で全通りを探索できるのでは curは０からスタート
def dfs(cur, times):
    global answer
    if cur == N:
        times.sort()
        arr = np.array(times)
        result = (arr[1:] - arr[:-1]).min()
        if result > answer:
            answer = result
    else:
        x = D[cur]
        dfs(cur + 1, times + [x])
        dfs(cur + 1, times + [24 - x])


answer = 0
dfs(0, [0, 24])
print(answer)

N = int(eval(input())) + 1
D = list(map(int, input().split())) + [0] + [24]
D.sort()
for i in range(1, N, 2):
    D[i] = 24 - D[i]
D.sort()
ans = 24
for i in range(N):
    ans = min(ans, abs(D[i + 1] - D[i]))
print(ans)

-import numpy as np - -N = int(eval(input())) -D = list(map(int, input().split())) -if N > 23: -    print((0)) -    exit() -if D.count(0) >= 2: -    print((0)) -    exit() -for i in range(1, 13): -    if D.count(i) >= 3: -        print((0)) -        exit() -for i in range(13): -    if (D.count(i) + D.count(i + 1)) == 4: -        print((1)) -        exit() -# 深さ優先探索で全通りを探索できるのでは curは０からスタート -def dfs(cur, times): -    global answer -    if cur == N: -        times.sort() -        arr = np.array(times) -        result = (arr[1:] - arr[:-1]).min() -        if result > answer: -            answer = result -    else: -        x = D[cur] -        dfs(cur + 1, times + [x]) -        dfs(cur + 1, times + [24 - x]) - - -answer = 0 -dfs(0, [0, 24]) -print(answer) +N = int(eval(input())) + 1 +D = list(map(int, input().split())) + [0] + [24] +D.sort() +for i in range(1, N, 2): +    D[i] = 24 - D[i] +D.sort() +ans = 24 +for i in range(N): +    ans = min(ans, abs(D[i + 1] - D[i])) +print(ans)