Problem:
In CODE FESTIVAL XXXX, there are N+1 participants from all over the world, including Takahashi.  Takahashi checked and found that the _time gap_ (defined below) between the local times in his city and the i-th person's city was D_i hours. The time gap between two cities is defined as follows. For two cities A and B, if the local time in city B is d o'clock at the moment when the local time in city A is 0 o'clock, then the time gap between these two cities is defined to be min(d,24-d) hours. Here, we are using 24-hour notation. That is, the local time in the i-th person's city is either d o'clock or 24-d o'clock at the moment when the local time in Takahashi's city is 0 o'clock, for example.  Then, for each pair of two people chosen from the N+1 people, he wrote out the time gap between their cities. Let the smallest time gap among them be s hours.  Find the maximum possible value of s.

Incorrect submission (verdict: Wrong Answer):
import sys
readline = sys.stdin.readline
sys.setrecursionlimit(10**8)
mod = 10**9+7
#mod = 998244353
INF = 10**18
eps = 10**-7

N = int(readline())
D = list(map(int,readline().split()))

c = [0]*13
c[0] = 1
for d in D:
    c[d] += 1

if c[0] >= 2 or c[12] >= 2:
    print(0)
    exit()
for i in range(1,12):
    if c[i] >= 3:
        print(0)
        exit()

bitsearchlist = []
notbitsearch = [False]*24
notbitsearch[0] = True
if c[12]:
    notbitsearch[12] = True


for i in range(1,12):
    if c[i] == 1:
        bitsearchlist.append(i)
    elif c[i] == 2:
        notbitsearch[i] = True
        notbitsearch[24-i] = True

print(bitsearchlist)
print(notbitsearch)


def count(List):
    anss = INF
    ret = INF
    for b in notbitsearch:
        if b:
            anss = min(anss,ret)
            ret = 0
        else:
            ret += 1
    anss = min(anss,ret)
    anss += 1
    return anss



L = len(bitsearchlist)

if L == 0:
    print(count(notbitsearch))
    exit()

ans = 0
for i in range(2**L):
    for j in range(L):
        if ((i >> j) & 1):
            notbitsearch[bitsearchlist[j]] = True
        else:
            notbitsearch[24-bitsearchlist[j]] = True
    ans = max(ans,count(notbitsearch))
    for j in range(L):
        if ((i >> j) & 1):
            notbitsearch[bitsearchlist[j]] = False
        else:
            notbitsearch[24-bitsearchlist[j]] = False

print(ans)


Fixed, accepted submission:
import sys
readline = sys.stdin.readline
sys.setrecursionlimit(10**8)
mod = 10**9+7
#mod = 998244353
INF = 10**18
eps = 10**-7

N = int(readline())

D = list(map(int,readline().split()))
cnt = [0]*13
for d in D:
    cnt[min(24-d,d)] += 1
cnt[0] += 1
for i in range(1,12):
    if cnt[i] >= 3:
        print(0)
        exit()
if cnt[0] >= 2 or cnt[12] >= 2:
    print(0)
    exit()

where = [0]*24
where[0] = 1
b = 0
if cnt[12]:
    where[12] = 1
for i in range(1,12):
    c = cnt[i]
    if c == 0:
        continue
    if c == 2:
        where[i] = 1
        where[24-i] = 1
        b = 0
    else:
        if b:
            where[i] = 1
            b = 0
        else:
            where[24-i] = 1
            b = 1

ans = INF
a = 1
for i in range(1,24):
    if where[i]:
        ans = min(ans,a)
        a = 1
    else:
        a += 1
ans = min(ans,a)
print(ans)