Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
from itertools import combinations
N = int(input())
A = np.array(list(map(int, input().split())), dtype= int)
X = A.sum()
A1 = np.cumsum(A)
mincost1 = -1
for r2 in range(1,N-2):
    Y = A1[r2]
    mincost2 = -1
    r1 = 1
    for i in np.arange(-1,2)+np.argmax(A1*(A1<=Y/2)):
        L = A1[i]
        R = Y - L
        cost = np.abs(R-L)
        if mincost2 < 0 or mincost2 >  cost:
            mincost2 = cost
            r1 = i
    P = A1[r1]
    Q = Y - A1[r1]

    mincost3 = -1
    r3 = N-1
    for i in  np.arange(-1,2)+np.argmax(A1*(A1<=(X+Y)/2)):
        L = A1[i] - Y
        R = X - Y - L
        cost = np.abs(R-L)
        if mincost3 < 0 or mincost3 >  cost:
            mincost3 = cost
            r3 = i

    R = A1[r3]-Y
    S = X-A1[r3]
    cost = max(P,Q,R,S) - min(P,Q,R,S)
    if mincost1 < 0 or mincost1 >  cost:
            mincost1 = cost
print(mincost1)

Fixed submission:
from itertools import accumulate
input()
*s, = accumulate(map(int, input().split()))
l,r,t = 0,2,s[-1]
c = t
for m in s[1:-2]:
    while t+m > s[r]+s[r+1]:
        r += 1
    while m > s[l]+s[l+1]:
        l += 1
    x = sorted([s[l],m-s[l],s[r]-m,t-s[r]])
    c = min(c,x[-1]-x[0])
print(c)

Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
from itertools import combinations
N = int(input())
A = np.array(list(map(int, input().split())), dtype= int)
X = A.sum()
A1 = np.cumsum(A)
mincost1 = -1
for r2 in range(1,N-2):
    Y = A1[r2]
    mincost2 = -1
    r1 = 1
    for i in range(0,r2):
        L = A1[i]
        R = Y - L
        cost = np.abs(R-L)
        if mincost2 < 0 or mincost2 >  cost:
            mincost2 = cost
            r1 = i
    P = A1[r1]
    Q = Y - A1[r1]

    mincost3 = -1
    r3 = N-1
    for i in range(r2+1,N):
        L = A1[i] - Y
        R = X - Y - L
        cost = np.abs(R-L)
        if mincost3 < 0 or mincost3 >  cost:
            mincost3 = cost
            r3 = i

    R = A1[r3]-Y
    S = X-A1[r3]
    cost = max(P,Q,R,S) - min(P,Q,R,S)
    if mincost1 < 0 or mincost1 >  cost:
            mincost1 = cost
print(mincost1)


Fixed submission:
from itertools import accumulate
input()
*s, = accumulate(map(int, input().split()))
l,r,t = 0,2,s[-1]
c = t
for m in s[1:-2]:
    while t+m > s[r]+s[r+1]:
        r += 1
    while m > s[l]+s[l+1]:
        l += 1
    x = sorted([s[l],m-s[l],s[r]-m,t-s[r]])
    c = min(c,x[-1]-x[0])
print(c)

Buggy python submission (verdict: Runtime Error):
import numpy as np
from itertools import combinations
N = int(input())
A = np.array(list(map(int, input().split())), dtype= int)
X = A.sum()
A1 = np.cumsum(A)
mincost = -1
for r1, r2, r3 in combinations(range(1,N), 3):
    P = A1[r1]
    Q = Y - A1[r1]
    R = A1[r3]-Y
    S = X-A1[r3]
    cost = max(P,Q,R,S) - min(P,Q,R,S)
    if mincost < 0 or mincost >  cost:
        mincost = cost
print(mincost)

Fixed submission:
from itertools import accumulate
input()
*s, = accumulate(map(int, input().split()))
l,r,t = 0,2,s[-1]
c = t
for m in s[1:-2]:
    while t+m > s[r]+s[r+1]:
        r += 1
    while m > s[l]+s[l+1]:
        l += 1
    x = sorted([s[l],m-s[l],s[r]-m,t-s[r]])
    c = min(c,x[-1]-x[0])
print(c)