n,*d=list(map(int,open(0).read().split()));s=sorted

l=[0]+s([x if i%2 else 24-x for i,x in enumerate(s(d))])+[24]

print((min(j-i for i,j in zip(l,l[1:]))))
_,d=open(0);s=sorted;l=[0]+s([x if i%2else 24-x for i,x in enumerate(s(list(map(int,d.split()))))])+[24];print((min(j-i for i,j in zip(l,l[1:]))))
n, *d = list(map(int, open(0).read().split()))
s = sorted
l = [0] + s([x if i % 2 else 24 - x for i, x in enumerate(s(d))]) + [24]
print((min(j - i for i, j in zip(l, l[1:]))))

_, d = open(0)
s = sorted
l = (
    [0]
    + s([x if i % 2 else 24 - x for i, x in enumerate(s(list(map(int, d.split()))))])
    + [24]
)
print((min(j - i for i, j in zip(l, l[1:]))))

-n, *d = list(map(int, open(0).read().split())) +_, d = open(0) -l = [0] + s([x if i % 2 else 24 - x for i, x in enumerate(s(d))]) + [24] +l = ( +    [0] +    + s([x if i % 2 else 24 - x for i, x in enumerate(s(list(map(int, d.split()))))]) +    + [24] +)