def solve(N, D):
    fill = [0] * 24
    fill[0] = 1

    left = False
    for i in range(N):
        if D[i] == 0:
            print(0)
            return 0
        elif D[i] == 12:
            if fill[12] == 1:
                print(0)
                return 0
            else:
                fill[12] = 1
        else:
            if not left:
                if fill[D[i]] == 0:
                    fill[D[i]] = 1
                    left = True
                elif fill[24-D[i]] == 0:
                    fill[24-D[i]] = 1
                    left = False
                else:
                    print(0)
                    return 0
            else:
                if fill[24-D[i]] == 0:
                    fill[24-D[i]] = 1
                    left = False
                elif fill[D[i]] == 0:
                    fill[D[i]] = 1
                    left = True
                else:
                    print(0)
                    return 0

    s = 24
    cnt = 0
    for i in range(1, 24):
        if i == 23:
            if fill[i] == 0:
                cnt += 1
                s = min(s, cnt + 1)
            else:
                s = min(s, cnt + 1)
        else:
            if fill[i] == 0:
                cnt += 1
            else:
                s = min(s, cnt + 1)
                cnt = 0
    print(s)

if __name__ == '__main__':
    N = int(input())
    D = list(map(int, input().split()))
    solve(N, sorted(D))
