from itertools import product

import random



def solve(n,dl):

    # n = int(input())

    # dl = list(map(int, input().split()))



    if 0 in dl:

        return 0



    doubles = []

    dl1 = []

    dl2 = []

    for i in range(1,13):

        i_cnt = dl.count(i)

        if i_cnt > 2:

            return 0

        elif i_cnt == 2:

            dl2.append(24-i)

            dl2.append(i)

        elif i_cnt == 1:

            dl1.append(i)        



    ans = 0

    ite = list(product(list(range(2)),repeat=len(dl1)))

    for pattern in ite:

        dl24 = [0,24]

        for i, v in enumerate(pattern):

            if v == 1:

                dl24.append(24-dl1[i])

            else:

                dl24.append(dl1[i])

        dl24 = dl24 + dl2

        dl24.sort()

        diff_min = 24

        # print(dl24)

        if len(dl24) == 1:

            ans = max(ans, min(dl24[0], 24-dl24[0]))

        else:

            for a,b in zip(dl24[:-1],dl24[1:]):

                diff = b-a

                if diff != 24:

                    diff_min = min(diff_min,diff)

            ans = max(diff_min,ans)

    return ans





def solve2(n,dl):

    ite = list(product(list(range(2)),repeat=len(dl)))

    ans = 0

    for pattern in ite:

        dl_new = [0]

        for i, v in enumerate(pattern):

            if v == 1:

                dl_new.append(24-dl[i])

            else:

                dl_new.append(dl[i])

        dl_new.sort()

        diff_min = 24

        for a,b in zip(dl_new[:-1], dl_new[1:]):

            diff = b-a

            diff_min = min(diff_min, diff)

        ans = max(ans,diff_min)

    return ans





if __name__ == "__main__":

    n = int(eval(input()))

    dl = list(map(int, input().split()))

    ans = solve(n,dl)

    print(ans)

    # for _ in range(10):

    #     n = random.randint(1,10)

    #     dl = [random.randint(1,12) for _ in range(n)]

    #     ans1 = solve(n, dl[:])

        # ans2 = solve2(n,dl[:])

        # if ans1 != ans2:

        #     print(n)

        #     print(dl)

        #     print(ans1)

        #     print(ans2)

        #     print('----')
n = int(eval(input()))

dl = list(map(int, input().split()))



if 0 in dl:

    print((0))

    exit()



dl.sort()

dl1 = [0,24]

dl2 = [0,24]

for i, d in enumerate(dl):

    if i%2 == 0:

        dl1.append(d)

        dl2.append(24-d)

    else:

        dl1.append(24-d)

        dl2.append(d)



dl1.sort()

dl2.sort()



min_1 = 24

for a,b in zip(dl1[1:],dl1[:-1]):

    diff = a-b

    min_1 = min(min_1,diff)



min_2 = 24

for a,b in zip(dl2[1:],dl2[:-1]):

    diff = a-b

    min_2 = min(min_2,diff)



ans = max(min_1,min_2)

print(ans)

from itertools import product
import random


def solve(n, dl):
    # n = int(input())
    # dl = list(map(int, input().split()))
    if 0 in dl:
        return 0
    doubles = []
    dl1 = []
    dl2 = []
    for i in range(1, 13):
        i_cnt = dl.count(i)
        if i_cnt > 2:
            return 0
        elif i_cnt == 2:
            dl2.append(24 - i)
            dl2.append(i)
        elif i_cnt == 1:
            dl1.append(i)
    ans = 0
    ite = list(product(list(range(2)), repeat=len(dl1)))
    for pattern in ite:
        dl24 = [0, 24]
        for i, v in enumerate(pattern):
            if v == 1:
                dl24.append(24 - dl1[i])
            else:
                dl24.append(dl1[i])
        dl24 = dl24 + dl2
        dl24.sort()
        diff_min = 24
        # print(dl24)
        if len(dl24) == 1:
            ans = max(ans, min(dl24[0], 24 - dl24[0]))
        else:
            for a, b in zip(dl24[:-1], dl24[1:]):
                diff = b - a
                if diff != 24:
                    diff_min = min(diff_min, diff)
            ans = max(diff_min, ans)
    return ans


def solve2(n, dl):
    ite = list(product(list(range(2)), repeat=len(dl)))
    ans = 0
    for pattern in ite:
        dl_new = [0]
        for i, v in enumerate(pattern):
            if v == 1:
                dl_new.append(24 - dl[i])
            else:
                dl_new.append(dl[i])
        dl_new.sort()
        diff_min = 24
        for a, b in zip(dl_new[:-1], dl_new[1:]):
            diff = b - a
            diff_min = min(diff_min, diff)
        ans = max(ans, diff_min)
    return ans


if __name__ == "__main__":
    n = int(eval(input()))
    dl = list(map(int, input().split()))
    ans = solve(n, dl)
    print(ans)
    # for _ in range(10):
    #     n = random.randint(1,10)
    #     dl = [random.randint(1,12) for _ in range(n)]
    #     ans1 = solve(n, dl[:])
    # ans2 = solve2(n,dl[:])
    # if ans1 != ans2:
    #     print(n)
    #     print(dl)
    #     print(ans1)
    #     print(ans2)
    #     print('----')

n = int(eval(input()))
dl = list(map(int, input().split()))
if 0 in dl:
    print((0))
    exit()
dl.sort()
dl1 = [0, 24]
dl2 = [0, 24]
for i, d in enumerate(dl):
    if i % 2 == 0:
        dl1.append(d)
        dl2.append(24 - d)
    else:
        dl1.append(24 - d)
        dl2.append(d)
dl1.sort()
dl2.sort()
min_1 = 24
for a, b in zip(dl1[1:], dl1[:-1]):
    diff = a - b
    min_1 = min(min_1, diff)
min_2 = 24
for a, b in zip(dl2[1:], dl2[:-1]):
    diff = a - b
    min_2 = min(min_2, diff)
ans = max(min_1, min_2)
print(ans)

-from itertools import product -import random - - -def solve(n, dl): -    # n = int(input()) -    # dl = list(map(int, input().split())) -    if 0 in dl: -        return 0 -    doubles = [] -    dl1 = [] -    dl2 = [] -    for i in range(1, 13): -        i_cnt = dl.count(i) -        if i_cnt > 2: -            return 0 -        elif i_cnt == 2: -            dl2.append(24 - i) -            dl2.append(i) -        elif i_cnt == 1: -            dl1.append(i) -    ans = 0 -    ite = list(product(list(range(2)), repeat=len(dl1))) -    for pattern in ite: -        dl24 = [0, 24] -        for i, v in enumerate(pattern): -            if v == 1: -                dl24.append(24 - dl1[i]) -            else: -                dl24.append(dl1[i]) -        dl24 = dl24 + dl2 -        dl24.sort() -        diff_min = 24 -        # print(dl24) -        if len(dl24) == 1: -            ans = max(ans, min(dl24[0], 24 - dl24[0])) -        else: -            for a, b in zip(dl24[:-1], dl24[1:]): -                diff = b - a -                if diff != 24: -                    diff_min = min(diff_min, diff) -            ans = max(diff_min, ans) -    return ans - - -def solve2(n, dl): -    ite = list(product(list(range(2)), repeat=len(dl))) -    ans = 0 -    for pattern in ite: -        dl_new = [0] -        for i, v in enumerate(pattern): -            if v == 1: -                dl_new.append(24 - dl[i]) -            else: -                dl_new.append(dl[i]) -        dl_new.sort() -        diff_min = 24 -        for a, b in zip(dl_new[:-1], dl_new[1:]): -            diff = b - a -            diff_min = min(diff_min, diff) -        ans = max(ans, diff_min) -    return ans - - -if __name__ == "__main__": -    n = int(eval(input())) -    dl = list(map(int, input().split())) -    ans = solve(n, dl) -    print(ans) -    # for _ in range(10): -    #     n = random.randint(1,10) -    #     dl = [random.randint(1,12) for _ in range(n)] -    #     ans1 = solve(n, dl[:]) -    # ans2 = solve2(n,dl[:]) -    # if ans1 != ans2: -    #     print(n) -    #     print(dl) -    #     print(ans1) -    #     print(ans2) +n = int(eval(input())) +dl = list(map(int, input().split())) +if 0 in dl: +    print((0)) +    exit() +dl.sort() +dl1 = [0, 24] +dl2 = [0, 24] +for i, d in enumerate(dl): +    if i % 2 == 0: +        dl1.append(d) +        dl2.append(24 - d) +    else: +        dl1.append(24 - d) +        dl2.append(d) +dl1.sort() +dl2.sort() +min_1 = 24 +for a, b in zip(dl1[1:], dl1[:-1]): +    diff = a - b +    min_1 = min(min_1, diff) +min_2 = 24 +for a, b in zip(dl2[1:], dl2[:-1]): +    diff = a - b +    min_2 = min(min_2, diff) +ans = max(min_1, min_2) +print(ans)