
import collections

n = int(input())

inp_list = list(map(int, input().split()))
inp_list.append(0)

c = collections.Counter(inp_list)
a = c.most_common()


def ura(time):
    if time == 12:
        time = 12
    elif time == 0:
        time = 0
    else:
        time = 24 - time

    return time


member = []

for tup in a:
    if tup[1] > 1:
        member.append(tup[0])
        member.append(tup[0])
    elif tup[1] == 1:
        member.append(tup[0])


ans = 0

for i in range(2**len(member)):
    trry = format(i, '0' + str(len(member))+'b')
    time_diff = 24

    for ii in range(len(member)-1):
        for iii in range(ii+1, len(member)):
            A = member[ii]
            if trry[iii] == '0':
                B = member[iii]
            else:
                B = ura(member[iii])
            a_b = abs(A-B)
            b_a = min(A, B)+24-max(A, B)
            time_diff = min(time_diff, a_b, b_a)

    ans = max(ans, time_diff)

print(ans)