N = int(eval(input()))

D = [0] + list(map(int, input().split()))

Diffs = [[[0, 0] for i in range(N+1)] for j in range(N+1)]



# ある都市間の時差の取りうる値は2種類のみ

# 先ずはそれを全列挙

candidates = []

for i in range(N+1):

  for j in range(i+1, N+1):

    di, dj = D[i], D[j]

    diff1, diff2 = abs(di-dj), min(24-di-dj, di+dj)

    candidates.extend([[i, j, diff1, 0], [i, j, diff2, 1]])

    Diffs[i][j] = [diff1, diff2]



# 上で全列挙した時差に関して、その時差が全体の最小値となり得るかどうかを確認していく

# 最小値となり得るかどうかを確認したい時差の値をdiffとすると、

# 任意の2都市間の時差がdiff以上となる必要があり、そのような時間の設定方法があるかどうかを確認する

# 矛盾するかどうかは都市を2色で塗り分ける要領で確認できる

ans = 0

for idx1, idx2, diff, c in candidates:

  conditions = [-1] * (N+1)

  if c == 0:

    conditions[idx1] = conditions[idx2] = 0

  else:

    conditions[idx1] = 0; conditions[idx2] = 1

  res = True

  for i in range(N+1):

    for j in range(i+1, N+1):

      if idx1 == i and idx2 == j:

        continue

      diff1, diff2 = Diffs[i][j]

      if diff1 < diff and diff2 < diff:

        res = False

        break

      elif diff1 < diff:

        c1, c2 = conditions[i], conditions[j]

        if c1 < 0 and c2 < 0:

          conditions[i] = 0; conditions[j] = 1

        elif c1 < 0:

          conditions[i] = 1 - c2

        elif c2 < 0:

          conditions[j] = 1 - c1

        else:

          if c1 == c2:

            res = False

            break

      elif diff2 < diff:

        c1, c2 = conditions[i], conditions[j]

        if c1 < 0 and c2 < 0:

          conditions[i] = conditions[j] = 0

        elif c1 < 0:

          conditions[i] = c2

        elif c2 < 0:

          conditions[j] = c1

        else:

          if c1 != c2:

            res = False

            break

    else:

      continue

    break

  if res:

    ans = max(ans, diff)



print(ans)
# 想定解法



N = int(eval(input()))

D = list(map(int, input().split()))

num_time = [0] * 13

num_time[0] = 2

num_time[12] = 1



fixed = [0]

unfixed = []

for d in D:

  num_time[d] += 1

  if d == 12:

    fixed.append(12)

  if num_time[d] >= 3:

    print((0))

    quit()



for t in range(1, 12):

  if num_time[t] == 2:

    fixed.extend([t, 24 - t])

  elif num_time[t] == 1:

    unfixed.append(t)



ans = 0

n = len(unfixed)

for i in range(2**n):

  t = fixed.copy() + [24]

  # bitが0のものはt, 1のものは24-tとして設定する

  for j in range(n):

    if i >> j & 1:

      t.append(unfixed[j])

    else:

      t.append(24 - unfixed[j])

  t.sort()

  s = 24

  m = len(t)

  for k in range(m-1):

    _s = t[k+1] - t[k]

    s = min(s, _s)

  ans = max(ans, s)



print(ans)
N = int(eval(input()))
D = [0] + list(map(int, input().split()))
Diffs = [[[0, 0] for i in range(N + 1)] for j in range(N + 1)]
# ある都市間の時差の取りうる値は2種類のみ
# 先ずはそれを全列挙
candidates = []
for i in range(N + 1):
    for j in range(i + 1, N + 1):
        di, dj = D[i], D[j]
        diff1, diff2 = abs(di - dj), min(24 - di - dj, di + dj)
        candidates.extend([[i, j, diff1, 0], [i, j, diff2, 1]])
        Diffs[i][j] = [diff1, diff2]
# 上で全列挙した時差に関して、その時差が全体の最小値となり得るかどうかを確認していく
# 最小値となり得るかどうかを確認したい時差の値をdiffとすると、
# 任意の2都市間の時差がdiff以上となる必要があり、そのような時間の設定方法があるかどうかを確認する
# 矛盾するかどうかは都市を2色で塗り分ける要領で確認できる
ans = 0
for idx1, idx2, diff, c in candidates:
    conditions = [-1] * (N + 1)
    if c == 0:
        conditions[idx1] = conditions[idx2] = 0
    else:
        conditions[idx1] = 0
        conditions[idx2] = 1
    res = True
    for i in range(N + 1):
        for j in range(i + 1, N + 1):
            if idx1 == i and idx2 == j:
                continue
            diff1, diff2 = Diffs[i][j]
            if diff1 < diff and diff2 < diff:
                res = False
                break
            elif diff1 < diff:
                c1, c2 = conditions[i], conditions[j]
                if c1 < 0 and c2 < 0:
                    conditions[i] = 0
                    conditions[j] = 1
                elif c1 < 0:
                    conditions[i] = 1 - c2
                elif c2 < 0:
                    conditions[j] = 1 - c1
                else:
                    if c1 == c2:
                        res = False
                        break
            elif diff2 < diff:
                c1, c2 = conditions[i], conditions[j]
                if c1 < 0 and c2 < 0:
                    conditions[i] = conditions[j] = 0
                elif c1 < 0:
                    conditions[i] = c2
                elif c2 < 0:
                    conditions[j] = c1
                else:
                    if c1 != c2:
                        res = False
                        break
        else:
            continue
        break
    if res:
        ans = max(ans, diff)
print(ans)

# 想定解法
N = int(eval(input()))
D = list(map(int, input().split()))
num_time = [0] * 13
num_time[0] = 2
num_time[12] = 1
fixed = [0]
unfixed = []
for d in D:
    num_time[d] += 1
    if d == 12:
        fixed.append(12)
    if num_time[d] >= 3:
        print((0))
        quit()
for t in range(1, 12):
    if num_time[t] == 2:
        fixed.extend([t, 24 - t])
    elif num_time[t] == 1:
        unfixed.append(t)
ans = 0
n = len(unfixed)
for i in range(2**n):
    t = fixed.copy() + [24]
    # bitが0のものはt, 1のものは24-tとして設定する
    for j in range(n):
        if i >> j & 1:
            t.append(unfixed[j])
        else:
            t.append(24 - unfixed[j])
    t.sort()
    s = 24
    m = len(t)
    for k in range(m - 1):
        _s = t[k + 1] - t[k]
        s = min(s, _s)
    ans = max(ans, s)
print(ans)

+# 想定解法 -D = [0] + list(map(int, input().split())) -Diffs = [[[0, 0] for i in range(N + 1)] for j in range(N + 1)] -# ある都市間の時差の取りうる値は2種類のみ -# 先ずはそれを全列挙 -candidates = [] -for i in range(N + 1): -    for j in range(i + 1, N + 1): -        di, dj = D[i], D[j] -        diff1, diff2 = abs(di - dj), min(24 - di - dj, di + dj) -        candidates.extend([[i, j, diff1, 0], [i, j, diff2, 1]]) -        Diffs[i][j] = [diff1, diff2] -# 上で全列挙した時差に関して、その時差が全体の最小値となり得るかどうかを確認していく -# 最小値となり得るかどうかを確認したい時差の値をdiffとすると、 -# 任意の2都市間の時差がdiff以上となる必要があり、そのような時間の設定方法があるかどうかを確認する -# 矛盾するかどうかは都市を2色で塗り分ける要領で確認できる +D = list(map(int, input().split())) +num_time = [0] * 13 +num_time[0] = 2 +num_time[12] = 1 +fixed = [0] +unfixed = [] +for d in D: +    num_time[d] += 1 +    if d == 12: +        fixed.append(12) +    if num_time[d] >= 3: +        print((0)) +        quit() +for t in range(1, 12): +    if num_time[t] == 2: +        fixed.extend([t, 24 - t]) +    elif num_time[t] == 1: +        unfixed.append(t) -for idx1, idx2, diff, c in candidates: -    conditions = [-1] * (N + 1) -    if c == 0: -        conditions[idx1] = conditions[idx2] = 0 -    else: -        conditions[idx1] = 0 -        conditions[idx2] = 1 -    res = True -    for i in range(N + 1): -        for j in range(i + 1, N + 1): -            if idx1 == i and idx2 == j: -                continue -            diff1, diff2 = Diffs[i][j] -            if diff1 < diff and diff2 < diff: -                res = False -                break -            elif diff1 < diff: -                c1, c2 = conditions[i], conditions[j] -                if c1 < 0 and c2 < 0: -                    conditions[i] = 0 -                    conditions[j] = 1 -                elif c1 < 0: -                    conditions[i] = 1 - c2 -                elif c2 < 0: -                    conditions[j] = 1 - c1 -                else: -                    if c1 == c2: -                        res = False -                        break -            elif diff2 < diff: -                c1, c2 = conditions[i], conditions[j] -                if c1 < 0 and c2 < 0: -                    conditions[i] = conditions[j] = 0 -                elif c1 < 0: -                    conditions[i] = c2 -                elif c2 < 0: -                    conditions[j] = c1 -                else: -                    if c1 != c2: -                        res = False -                        break +n = len(unfixed) +for i in range(2**n): +    t = fixed.copy() + [24] +    # bitが0のものはt, 1のものは24-tとして設定する +    for j in range(n): +        if i >> j & 1: +            t.append(unfixed[j]) -            continue -        break -    if res: -        ans = max(ans, diff) +            t.append(24 - unfixed[j]) +    t.sort() +    s = 24 +    m = len(t) +    for k in range(m - 1): +        _s = t[k + 1] - t[k] +        s = min(s, _s) +    ans = max(ans, s)