# coding: utf-8

import itertools


dd = {}
for i in range(13):
    for j in range(i, 13):
        dd[(i, j)] = max(min(i + j, 24 - i - j), abs(i - j))

def main():
    n = int(input())
    d = list(map(int, input().split()))
    d.append(0)
    s = 12
    for i in range(n + 1):
        a = d[i]
        for j in range(i + 1, n + 1):
            b = d[j]
            s = min(s, dd[(min(a, b), max(a, b))])
    return s

print(main())
