N = int(eval(input()))

D = [int(d) for d in input().split()]



D.append(0)

D.sort()

ans = 0

time1 = []

time2 = []

for i in range(N+1):

    if D.count(D[i]) == 2:

        if D[i] == 0:

            ans = -1

            break

        time2.append(D[i])

        time2.append(24-D[i])

    if D.count(D[i]) + D.count(24-D[i]) > 2:

        ans = -1

        break

    if D.count(D[i]) == 1:

        time1.append(D[i])



time2 = set(time2)    

if ans == 0:

    for i in range(2**len(time1)):

        temp = []

        for j in range(len(time1)):

            if i & 1<<j:

                temp.append(24-time1[j])

            else:

                temp.append(time1[j])

        temp += list(time2)

        temp.sort()

        cnt = 24-temp[-1]

        if temp[-1] == 0:

            cnt = 0

        for k in range(len(temp)-1):

            cnt = min(cnt, temp[k+1]-temp[k])

        ans = max(ans, cnt)

else:

    ans = 0



print(ans)
N = int(eval(input()))

D = [int(d) for d in input().split()]



D.append(0)

D.sort()

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

    if i%2 == 0:

        D[i] = 24-D[i]

D.sort()

ans = min(D[-1], 24-D[-1])

for i in range(N):

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

print(ans)
N = int(eval(input()))
D = [int(d) for d in input().split()]
D.append(0)
D.sort()
ans = 0
time1 = []
time2 = []
for i in range(N + 1):
    if D.count(D[i]) == 2:
        if D[i] == 0:
            ans = -1
            break
        time2.append(D[i])
        time2.append(24 - D[i])
    if D.count(D[i]) + D.count(24 - D[i]) > 2:
        ans = -1
        break
    if D.count(D[i]) == 1:
        time1.append(D[i])
time2 = set(time2)
if ans == 0:
    for i in range(2 ** len(time1)):
        temp = []
        for j in range(len(time1)):
            if i & 1 << j:
                temp.append(24 - time1[j])
            else:
                temp.append(time1[j])
        temp += list(time2)
        temp.sort()
        cnt = 24 - temp[-1]
        if temp[-1] == 0:
            cnt = 0
        for k in range(len(temp) - 1):
            cnt = min(cnt, temp[k + 1] - temp[k])
        ans = max(ans, cnt)
else:
    ans = 0
print(ans)

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

-ans = 0 -time1 = [] -time2 = [] -for i in range(N + 1): -    if D.count(D[i]) == 2: -        if D[i] == 0: -            ans = -1 -            break -        time2.append(D[i]) -        time2.append(24 - D[i]) -    if D.count(D[i]) + D.count(24 - D[i]) > 2: -        ans = -1 -        break -    if D.count(D[i]) == 1: -        time1.append(D[i]) -time2 = set(time2) -if ans == 0: -    for i in range(2 ** len(time1)): -        temp = [] -        for j in range(len(time1)): -            if i & 1 << j: -                temp.append(24 - time1[j]) -            else: -                temp.append(time1[j]) -        temp += list(time2) -        temp.sort() -        cnt = 24 - temp[-1] -        if temp[-1] == 0: -            cnt = 0 -        for k in range(len(temp) - 1): -            cnt = min(cnt, temp[k + 1] - temp[k]) -        ans = max(ans, cnt) -else: -    ans = 0 +for i in range(1, N + 1): +    if i % 2 == 0: +        D[i] = 24 - D[i] +D.sort() +ans = min(D[-1], 24 - D[-1]) +for i in range(N): +    ans = min(ans, D[i + 1] - D[i])