N = int(input())
D = sorted([int(_) for _ in input().split()])
#最小値の最大値
if D[0] == 0:
    print(0)
    exit()

p = m = 0
a = 99

for d in D:
    #asign positive
    e = min(a, d - p, 24 - d - m)
    #asign negative
    f = min(a, d - m, 24 - d - p)
    if e < f:
        a = f
        m = d
    else:
        a = e
        p = d
print(a)
