def solve():
    n = int(input())
    arr = [int(i) for i in input().split()]
    arrset = set(arr)
 
    if max(arrset) == 0:
        print(0)
        return
    
    ans = 0 
    for i, v in enumerate(arr):
        for j, w in enumerate(arr):
            if i == j and v == w:
                continue
            tarr = [i, j, 24 - i, 24 - j]
            tans = []
            for k in tarr:
                for l in tarr:
                    tans.append(min(abs(k - l), 24 - abs(k - l)))
            ans = max(ans, max(tans))
    print(ans) 
 
 
if __name__ == "__main__":
    solve()