N = int(eval(input()))

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

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

    D[i] = 24-D[i]

D.insert(0,0)

dmin = 24

for i in range(N):

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

        a = D[i]

        b = D[j]

        if a>b:

            a,b = b,a

        d = b-a

        if d>12:

            d = 24-d

        dmin = min(dmin,d)

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

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

s = min(D)

if 12 in D:

    for i in range(N):

        if D[i]!=12:

            s = min(s,12-D[i])

    D.remove(12)

D = sorted(D)

E = []

for i in range(len(D)):

    if i%2==0:

        E.append(D[i])

    else:

        E.append(24-D[i])

for i in range(len(E)-1):

    for j in range(i+1,len(E)):

        a = E[i]

        b = E[j]

        d = abs(a-b)

        if d>12:

            d = 24-d

        s = min(s,d)

print(s)
N = int(eval(input()))
D = sorted(list(map(int, input().split())))
for i in range(0, N, 2):
    D[i] = 24 - D[i]
D.insert(0, 0)
dmin = 24
for i in range(N):
    for j in range(i + 1, N + 1):
        a = D[i]
        b = D[j]
        if a > b:
            a, b = b, a
        d = b - a
        if d > 12:
            d = 24 - d
        dmin = min(dmin, d)
print(dmin)

N = int(eval(input()))
D = list(map(int, input().split()))
s = min(D)
if 12 in D:
    for i in range(N):
        if D[i] != 12:
            s = min(s, 12 - D[i])
    D.remove(12)
D = sorted(D)
E = []
for i in range(len(D)):
    if i % 2 == 0:
        E.append(D[i])
    else:
        E.append(24 - D[i])
for i in range(len(E) - 1):
    for j in range(i + 1, len(E)):
        a = E[i]
        b = E[j]
        d = abs(a - b)
        if d > 12:
            d = 24 - d
        s = min(s, d)
print(s)

-D = sorted(list(map(int, input().split()))) -for i in range(0, N, 2): -    D[i] = 24 - D[i] -D.insert(0, 0) -dmin = 24 -for i in range(N): -    for j in range(i + 1, N + 1): -        a = D[i] -        b = D[j] -        if a > b: -            a, b = b, a -        d = b - a +D = list(map(int, input().split())) +s = min(D) +if 12 in D: +    for i in range(N): +        if D[i] != 12: +            s = min(s, 12 - D[i]) +    D.remove(12) +D = sorted(D) +E = [] +for i in range(len(D)): +    if i % 2 == 0: +        E.append(D[i]) +    else: +        E.append(24 - D[i]) +for i in range(len(E) - 1): +    for j in range(i + 1, len(E)): +        a = E[i] +        b = E[j] +        d = abs(a - b) -        dmin = min(dmin, d) -print(dmin) +        s = min(s, d) +print(s)