# -*- coding:utf-8 -*-
import sys

DBG_FLAG = 0

def p_dbg(str):
    if(DBG_FLAG == 1):
        sys.stdout.flush()
        print str

# 高橋君の都市とa,bの時差が
# (1) 12を超えないとき（例えば、2時間、4時間）⇒加算。
# (1) 12を超えるとき　（例えば、6時間、8時間）⇒減算して絶対値
def cal_diff(diff_a, diff_b):
    diff_a_24 = 24 - diff_a
    diff_b_24 = 24 - diff_b
    p_dbg("diff:"+str(diff_a)+","+str(diff_b))
    p_dbg(diff_a - diff_b)
    p_dbg(diff_b - diff_a),
    p_dbg(diff_a_24 - diff_b_24)
    p_dbg(diff_b_24 - diff_a_24)
    p_dbg(diff_a - diff_b_24)
    p_dbg(diff_b_24 - diff_a)
    p_dbg(diff_a_24 - diff_b)
    p_dbg(diff_b - diff_a_24)
    return max((diff_a - diff_b), (diff_b - diff_a),
               (diff_a_24 - diff_b_24), (diff_b_24 - diff_a_24),
               (diff_a - diff_b_24), (diff_b_24 - diff_a),
               (diff_a_24 - diff_b), (diff_b - diff_a_24))

city_num = int(raw_input())
diff_array = map(int, raw_input().split())
p_dbg(diff_array)

array = [[]]
min_diff = cal_diff(diff_array[0],diff_array[1])

for i in range(len(diff_array)):
    for j in range(len(diff_array)):
        if i == j:
            pass
        else:
            tmp_diff = cal_diff(diff_array[i],diff_array[j])
            p_dbg("tmp:"+str(tmp_diff)+":"+str(i)+","+str(j))
            if tmp_diff < min_diff:
                min_diff = tmp_diff

print min_diff
