import sys

N = int(sys.stdin.readline().strip())
D = [0] + [int(x) for x in sys.stdin.readline().strip().split()]

def kei(xs, n):
    xs = xs + [x + 24 for x in xs]
    m1 = min(abs(n - x) for x in xs)
    m2 = min(abs((24 - n) - x) for x in xs)
    if m1 >= m2:
        return n, m1
    else:
        return 24 - n, m2

def calc(D):
    D.sort()
    #print(D)
    n = len(D)
    if N > 24:
        return 0
    if D[1] == 0:
        return 0
    xs = D[:2]
    D = D[2:]
    r = xs[1] - xs[0]
    for d in D:
        #print(xs, d)
        c, m = kei(xs, d)
        #print("r", c, m)
        if m < r:
            r = m
        xs += [c]
    return r



print(calc(D))
