Buggy python submission (verdict: Runtime Error):
import sys
 
n = int(input())
a = list(map(int, input().split()))
aa = [0] + [sum(A[:i + 1]) for i in range(N)] 
ans = sys.maxsize
 
def getdiff(left, center, right):
    return abs((aa[center] - aa[left]) - (aa[right] - aa[center]))
 
L = 1
R = 3
 
for C in range(2, n):
    while L + 1 < C and getdiff(0, L, C) > getdiff(0, L + 1, C):
        L += 1
    while R + 1 < n and getdiff(C, R, n) > getdiff(C, R + 1, n):
        R += 1
    pqrs = [aa[L], aa[C] - aa[L], aa[R] - aa[C], aa[n] - aa[R]]
    pqrs.sort()
    ans = min(ans, pqrs[3] - pqrs[0])
 
print(ans)


Fixed submission:
import sys
 
n = int(input())
a = list(map(int, input().split()))
aa = [0]
for i in range(n):
    aa.append(aa[i] + a[i])
 
ans = sys.maxsize
 
def getdiff(left, center, right):
    return abs((aa[center] - aa[left]) - (aa[right] - aa[center]))
 
L = 1
R = 3
 
for C in range(2, n):
    while L + 1 < C and getdiff(0, L, C) > getdiff(0, L + 1, C):
        L += 1
    while R + 1 < n and getdiff(C, R, n) > getdiff(C, R + 1, n):
        R += 1
    pqrs = [aa[L], aa[C] - aa[L], aa[R] - aa[C], aa[n] - aa[R]]
    pqrs.sort()
    ans = min(ans, pqrs[3] - pqrs[0])
 
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int, input().split()))
cum_sum = [0] + [sum(A[:i + 1]) for i in range(N)]

ans = float("inf")


def get_diff(left, center, right):
    return abs((cum_sum[center] - cum_sum[left]) - (cum_sum[right] - cum_sum[center]))


l_point = 1
r_point = 3

for C in range(2, N):
    while l_point + 1 < C and get_diff(0, l_point, C) > get_diff(0, l_point + 1, C):
        l_point += 1
    while r_point + 1 < N and get_diff(C, r_point, N) > get_diff(C, r_point + 1, N):
        r_point += 1

    pqrs = [cum_sum[l_point], cum_sum[C] - cum_sum[l_point], cum_sum[r_point] - cum_sum[C], cum_sum[N] - cum_sum[r_point]]
    ans = min(ans, max(pqrs) - min(pqrs))

print(ans)


Fixed submission:
import sys
 
n = int(input())
a = list(map(int, input().split()))
aa = [0]
for i in range(n):
    aa.append(aa[i] + a[i])
 
ans = sys.maxsize
 
def getdiff(left, center, right):
    return abs((aa[center] - aa[left]) - (aa[right] - aa[center]))
 
L = 1
R = 3
 
for C in range(2, n):
    while L + 1 < C and getdiff(0, L, C) > getdiff(0, L + 1, C):
        L += 1
    while R + 1 < n and getdiff(C, R, n) > getdiff(C, R + 1, n):
        R += 1
    pqrs = [aa[L], aa[C] - aa[L], aa[R] - aa[C], aa[n] - aa[R]]
    pqrs.sort()
    ans = min(ans, pqrs[3] - pqrs[0])
 
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int, input().split()))
cum_sum = [0] + [sum(A[:i + 1]) for i in range(N)]

ans = float("inf")


def get_diff(left, center, right):
    return abs((cum_sum[center] - cum_sum[left]) - (cum_sum[right] - cum_sum[center]))


l_point = 1
r_point = 3

for C in range(2, N):
    while l_point + 1 < C and get_diff(0, l_point, C) > get_diff(0, l_point + 1, C):
        l_point += 1
    while r_point + 1 < N and get_diff(C, r_point, N) > get_diff(C, r_point + 1, N):
        r_point += 1

    pqrs = [cum_sum[l_point], cum_sum[C] - cum_sum[l_point], cum_sum[r_point] - cum_sum[C], cum_sum[N] - cum_sum[r_point]]
    ans = min(ans, max(pqrs) - min(pqrs))

print(ans)


Fixed submission:
import sys
 
n = int(input())
a = list(map(int, input().split()))
aa = [0]
for i in range(n):
    aa.append(aa[i] + a[i])
 
ans = sys.maxsize
 
def getdiff(left, center, right):
    return abs((aa[center] - aa[left]) - (aa[right] - aa[center]))
 
L = 1
R = 3
 
for C in range(2, n):
    while L + 1 < C and getdiff(0, L, C) > getdiff(0, L + 1, C):
        L += 1
    while R + 1 < n and getdiff(C, R, n) > getdiff(C, R + 1, n):
        R += 1
    pqrs = [aa[L], aa[C] - aa[L], aa[R] - aa[C], aa[n] - aa[R]]
    pqrs.sort()
    ans = min(ans, pqrs[3] - pqrs[0])
 
print(ans)

Buggy python submission (verdict: Runtime Error):
N = int(input())
A_list = list(map(int, input().split()))

summation = sum(A_list)
quarter_sum = summation / 4

temp_sum = 0
sum_list = []

for i in range(N):
    old_temp_sum = temp_sum
    temp_sum += A_list[i]
    if i == N - 1:
        sum_list.append(temp_sum)
        break

    if temp_sum >= quarter_sum:
        if abs(quarter_sum - temp_sum) >= abs(quarter_sum - old_temp_sum):
            sum_list.append(old_temp_sum)
            temp_sum = A_list[i]
        else:
            sum_list.append(temp_sum)
            temp_sum = 0

print(max(sum_list) - min(sum_list))


Fixed submission:
import sys
 
n = int(input())
a = list(map(int, input().split()))
aa = [0]
for i in range(n):
    aa.append(aa[i] + a[i])
 
ans = sys.maxsize
 
def getdiff(left, center, right):
    return abs((aa[center] - aa[left]) - (aa[right] - aa[center]))
 
L = 1
R = 3
 
for C in range(2, n):
    while L + 1 < C and getdiff(0, L, C) > getdiff(0, L + 1, C):
        L += 1
    while R + 1 < n and getdiff(C, R, n) > getdiff(C, R + 1, n):
        R += 1
    pqrs = [aa[L], aa[C] - aa[L], aa[R] - aa[C], aa[n] - aa[R]]
    pqrs.sort()
    ans = min(ans, pqrs[3] - pqrs[0])
 
print(ans)