from numpy import *
from scipy import *
n = int(input())
d = list(map(int,input().split()))
a = zeros(24)
a[0] += 1
for x in d:
    a[x]+=1

if a[0] >= 2:
    print(0)
    exit()

if a[12] >= 2:
    print(0)
    exit()

for x in a:
    if x >= 3:
        print(0)
        exit()

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

def calc_min_range(a):
    ret = inf
    range = 0
    for x in a[1:]:
        if x == 0:
            range += 1
        else:
            range += 1
            ret = min(ret,range)
            range = 0
    ret = min(ret,range)
    return ret
ans = 0
def dfs(depth, a):
    global ans
    if depth == 12:
        return
    if a[depth] == 1:
        a[depth], a[24-depth] = a[24-depth], a[depth]
        ans = max(ans,calc_min_range(a))
        dfs(depth+1, a)
        a[depth], a[24-depth] = a[24-depth], a[depth]
    ans = max(ans,calc_min_range(a))
    dfs(depth+1, a)
dfs(1, a)

print(ans)
