from numpy import *
from scipy import *

n = array(input(), dtype=int)
d = array(input().split(), dtype=int)
h = zeros(24, dtype=int)
h[0] = 1
h[d] += 1
ans = array(0, dtype=int)
if h[0] >= 2 or h[12] >= 2:
    print(ans)
    exit()
for x in h:
    if x >= 3:
        print(ans)
        exit()

for i in range(12):
    if h[i] >= 2:
        h[24-i] = 2

def dfs(depth, h):
    global ans
    r = 0
    res = inf
    for i in range(1,24):
        r += 1
        if h[i] != 0:
            res = min(res,r)
            r = 0
    res = min(res,r)
    ans = max(ans,res)
    if depth == 12:
        return
    if h[depth] == 1:
        h[depth], h[24-depth] = h[24-depth], h[depth]
        dfs(depth+1, h)
        h[depth], h[24-depth] = h[24-depth], h[depth]
    dfs(depth+1, h)

dfs(1, h)
print(ans)
