n = int(input())
dn = list(map(int, input().split()))
all_time = []
for i in range(n):
    all_time.append(dn[i])
    all_time.append(24 - dn[i])
all_time.sort()
print(abs(all_time[1] - all_time[-1]))