Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
d=list(map(int,input().split()))
if n>=24:
    print(0)
    exit()
if n==23:
    print(1)
op=2**n-1
ans=0
for i in range(op):
    t=[0]
    for j in range(n):
        if i&(2**j)>0:
            t.append(d[j])
        else:
            t.append(24-d[j])
    a=10000
    for p in range(1,1+n):
        for q in range(p):
            b=abs(t[p]-t[q])
            a=min(a,min(b,24-b))
    ans=max(ans,a)
print(ans)


Fixed submission:
n=int(input())
d=list(map(int,input().split()))
if n>=24:
    print(0)
    exit()
if n>=22:
    t=[]
    d.append(0)
    d.sort()
    f=1
    for i in range(n):
        if d[i]==d[i+1]:
            f+=1
        else:
            if f>2:
                print(0)
                exit()
            f=1
    print(1)
    exit()

op=2**n-1
ans=0
for i in range(op):
    t=[0]
    for j in range(n):
        if i&(2**j)>0:
            t.append(d[j])
        else:
            t.append(24-d[j])
    a=10000
    for p in range(1,1+n):
        for q in range(p):
            b=abs(t[p]-t[q])
            a=min(a,min(b,24-b))
    ans=max(ans,a)
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
d=list(map(int,input().split()))
if n>=24:
    print(0)
    exit()
op=2**n-1
ans=0
for i in range(op):
    t=[0]
    for j in range(n):
        if i&(2**j)>0:
            t.append(d[j])
        else:
            t.append(24-d[j])
    a=10000
    for p in range(1,1+n):
        for q in range(p):
            b=abs(t[p]-t[q])
            a=min(a,min(b,24-b))
    ans=max(ans,a)
print(ans)


Fixed submission:
n=int(input())
d=list(map(int,input().split()))
if n>=24:
    print(0)
    exit()
if n>=22:
    t=[]
    d.append(0)
    d.sort()
    f=1
    for i in range(n):
        if d[i]==d[i+1]:
            f+=1
        else:
            if f>2:
                print(0)
                exit()
            f=1
    print(1)
    exit()

op=2**n-1
ans=0
for i in range(op):
    t=[0]
    for j in range(n):
        if i&(2**j)>0:
            t.append(d[j])
        else:
            t.append(24-d[j])
    a=10000
    for p in range(1,1+n):
        for q in range(p):
            b=abs(t[p]-t[q])
            a=min(a,min(b,24-b))
    ans=max(ans,a)
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
d=list(map(int,input().split()))
if n>=24:
    print(0)
    exit()
op=[[0],[1]]
for i in range(n-1):
    tmp=[]
    for j in op:
        tmp.append(j+[0])
        tmp.append(j+[1])
    op=tmp
ans=0
for i in op:
    t=[0]
    for j in range(n):
        if i[j]==0:
            t.append(d[j])
        else:
            t.append(24-d[j])
    a=10000
    for p in range(1,1+n):
        for q in range(p):
            b=abs(t[p]-t[q])
            a=min(a,min(b,24-b))
    ans=max(ans,a)
print(ans)


Fixed submission:
n=int(input())
d=list(map(int,input().split()))
if n>=24:
    print(0)
    exit()
if n>=22:
    t=[]
    d.append(0)
    d.sort()
    f=1
    for i in range(n):
        if d[i]==d[i+1]:
            f+=1
        else:
            if f>2:
                print(0)
                exit()
            f=1
    print(1)
    exit()

op=2**n-1
ans=0
for i in range(op):
    t=[0]
    for j in range(n):
        if i&(2**j)>0:
            t.append(d[j])
        else:
            t.append(24-d[j])
    a=10000
    for p in range(1,1+n):
        for q in range(p):
            b=abs(t[p]-t[q])
            a=min(a,min(b,24-b))
    ans=max(ans,a)
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
d=list(map(int,input().split()))
if n>=24:
    print(0)
    exit()
op=[[0],[1]]
for i in range(n-1):
    tmp=[]
    for j in op:
        tmp.append(j+[0])
        tmp.append(j+[1])
    op=tmp
ans=0
for i in op:
    t=[0]
    for j in range(n):
        if i[j]==0:
            t.append(d[j])
        else:
            t.append(24-d[j])
    a=10000
    for p in range(1,1+n):
        for q in range(p):
            b=abs(t[p]-t[q])
            a=min(a,min(b,24-b))
    ans=max(ans,a)
print(ans)


Fixed submission:
n=int(input())
d=list(map(int,input().split()))
if n>=24:
    print(0)
    exit()
if n>=22:
    t=[]
    d.append(0)
    d.sort()
    f=1
    for i in range(n):
        if d[i]==d[i+1]:
            f+=1
        else:
            if f>2:
                print(0)
                exit()
            f=1
    print(1)
    exit()

op=2**n-1
ans=0
for i in range(op):
    t=[0]
    for j in range(n):
        if i&(2**j)>0:
            t.append(d[j])
        else:
            t.append(24-d[j])
    a=10000
    for p in range(1,1+n):
        for q in range(p):
            b=abs(t[p]-t[q])
            a=min(a,min(b,24-b))
    ans=max(ans,a)
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
d=list(map(int,input().split()))
if n>=24:
    print(0)
    exit()
op=[[0],[1]]
for i in range(n-1):
    tmp=[]
    for j in op:
        tmp.append(j+[0])
        tmp.append(j+[1])
    op=tmp
ans=0
for i in op:
    t=[0]
    for j in range(n):
        if i[j]==0:
            t.append(d[j])
        else:
            t.append(24-d[j])
    a=10000
    for p in range(1+n):
        for q in range(1+n):
            if p>q:
                b=abs(t[p]-t[q])
                a=min(a,min(b,24-b))
    ans=max(ans,a)
print(ans)


Fixed submission:
n=int(input())
d=list(map(int,input().split()))
if n>=24:
    print(0)
    exit()
if n>=22:
    t=[]
    d.append(0)
    d.sort()
    f=1
    for i in range(n):
        if d[i]==d[i+1]:
            f+=1
        else:
            if f>2:
                print(0)
                exit()
            f=1
    print(1)
    exit()

op=2**n-1
ans=0
for i in range(op):
    t=[0]
    for j in range(n):
        if i&(2**j)>0:
            t.append(d[j])
        else:
            t.append(24-d[j])
    a=10000
    for p in range(1,1+n):
        for q in range(p):
            b=abs(t[p]-t[q])
            a=min(a,min(b,24-b))
    ans=max(ans,a)
print(ans)

Buggy python submission (verdict: Runtime Error):
n=int(input())
d=list(map(int,input().split()))
if n>=24:
    print(0)
    exit()
op=[[0],[1]]
for i in range(n-1):
    tmp=[]
    for j in op:
        tmp.append(j+[0])
        tmp.append(j+[1])
    op=tmp
ans=0
for i in op:
    t=[0]
    for j in range(n):
        if i[j]==0:
            t.append(d[i])
        else:
            t.append(24-d[i])
    a=10000
    for p in range(1+n):
        for q in range(1+n):
            if p>q:
                b=abs(t[p]-t[q])
                a=min(a,min(b,24-b))
    ans=max(ans,a)
print(ans)

Fixed submission:
n=int(input())
d=list(map(int,input().split()))
if n>=24:
    print(0)
    exit()
if n>=22:
    t=[]
    d.append(0)
    d.sort()
    f=1
    for i in range(n):
        if d[i]==d[i+1]:
            f+=1
        else:
            if f>2:
                print(0)
                exit()
            f=1
    print(1)
    exit()

op=2**n-1
ans=0
for i in range(op):
    t=[0]
    for j in range(n):
        if i&(2**j)>0:
            t.append(d[j])
        else:
            t.append(24-d[j])
    a=10000
    for p in range(1,1+n):
        for q in range(p):
            b=abs(t[p]-t[q])
            a=min(a,min(b,24-b))
    ans=max(ans,a)
print(ans)