n,t=open(0)

n=int(n)+1

d=[t if i%2else(24-t)%24for i,t in enumerate([0]+sorted(map(int,t.split())))]

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

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

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