from collections import Counter, defaultdict
import sys
sys.setrecursionlimit(10 ** 5 + 10)
# input = sys.stdin.readline
from math import factorial
import heapq, bisect
import math
import itertools


import queue
from collections import deque


def main():
    num = int(input())
    data = list(map(int, input().split()))
    count = Counter(data)

    ans = 0
    for i in range(2 ** 11):
        bin_list = bin(i)[2:]
        bin_list = bin_list.zfill(11)
        bin_list = list(map(int, list(bin_list)))
        now_data = [0, 24]

        if count[12] >= 2:
            print(0)
            sys.exit()
        elif count[12] == 1:
            now_data.append(12)

        if count[0] >= 1:
            print(0)
            sys.exit()


        for j in range(1, 12):
            if count[j] == 0:
                continue
            elif count[j] >= 3:
                print(0)
                sys.exit()
            elif count[j] == 2:
                now_data.append(j)
                now_data.append(24 - j)
            elif bin_list[j - 1]:
                now_data.append(j)
            else:
                now_data.append(24 - j)
        now_data.sort()

        kari = 12
        # print(now_data)
        for j in range(len(now_data) - 1):
            kari = min(kari, now_data[j + 1] - now_data[j])
        ans = max(ans, kari)

    print(ans)




if __name__ == '__main__':
    main()
    # test()

