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

debug = True

while True:
    changed = False
    i = 1
    while i < N - 1:
        if (A[i] > 0) and (A[i - 1] < 0) and (A[i + 1] < 0):
            A[i] = A[i] * -1
            A[i - 1] = A[i - 1] * -1
            changed = True
            if debug: print("change 0:" + str(A))
            i = i + 3
        else:
            i = i + 1
    for i in range(N - 1):
        if (A[i] < 0) and (A[i + 1] < 0):
            A[i] = A[i] * -1
            A[i + 1] = A[i + 1] * -1
            changed = True
            if debug: print("change 1:" + str(A))
    for i in range(N - 1):
        if (A[i] < 0):
            val = A[i] * -1
            if (i > 0):
                if A[i + 1] < A[i - 1]:
                    if val > A[i + 1]:
                        A[i] = A[i] * -1
                        A[i + 1] = A[i + 1] * -1
                        changed = True
                        if debug: print("change 2:" + str(A))
                else:
                    if val > A[i - 1]:
                        A[i] = A[i] * -1
                        A[i - 1] = A[i - 1] * -1
                        changed = True
                        if debug: print("change 3:" + str(A))
            else:
                if val > A[i + 1]:
                    A[i] = A[i] * -1
                    A[i + 1] = A[i + 1] * -1
                    changed = True
                    if debug: print("change 4:" + str(A))
    if (not changed):
        break


print(sum(A))



Fixed submission:
N = int(input())
A = list(map(int,input().split()))

minus_cnt = 0
abs_sum = 0
min_abs_val = 1000000000
for i in range(N):
    abs_val = abs(A[i])
    abs_sum = abs_sum + abs_val
    if abs_val < min_abs_val:
        min_abs_val = abs_val
    if A[i] < 0:
        minus_cnt = minus_cnt + 1

B_max_sum = 0
if (minus_cnt % 2 == 0) or (min_abs_val == 0):
    B_max_sum = abs_sum
else:
    B_max_sum = abs_sum - min_abs_val * 2

print(B_max_sum)

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

debug = True

while True:
    changed = False
    i = 1
    while i < N - 1:
        if (A[i] > 0) and (A[i - 1] < 0) and (A[i + 1] < 0):
            A[i] = A[i] * -1
            A[i - 1] = A[i - 1] * -1
            changed = True
            if debug: print("change 0:" + str(A))
            i = i + 3
        else:
            i = i + 1
    for i in range(N - 1):
        if (A[i] < 0) and (A[i + 1] < 0):
            A[i] = A[i] * -1
            A[i + 1] = A[i + 1] * -1
            changed = True
            if debug: print("change 1:" + str(A))
    for i in range(N - 1):
        if (A[i] < 0):
            val = A[i] * -1
            if (i > 0):
                if A[i + 1] < A[i - 1]:
                    if val > A[i + 1]:
                        A[i] = A[i] * -1
                        A[i + 1] = A[i + 1] * -1
                        changed = True
                        if debug: print("change 2:" + str(A))
                else:
                    if val > A[i - 1]:
                        A[i] = A[i] * -1
                        A[i - 1] = A[i - 1] * -1
                        changed = True
                        if debug: print("change 3:" + str(A))
            else:
                if val > A[i + 1]:
                    A[i] = A[i] * -1
                    A[i + 1] = A[i + 1] * -1
                    changed = True
                    if debug: print("change 4:" + str(A))
    if (not changed):
        break


print(sum(A))



Fixed submission:
N = int(input())
A = list(map(int,input().split()))

minus_cnt = 0
abs_sum = 0
min_abs_val = 1000000000
for i in range(N):
    abs_val = abs(A[i])
    abs_sum = abs_sum + abs_val
    if abs_val < min_abs_val:
        min_abs_val = abs_val
    if A[i] < 0:
        minus_cnt = minus_cnt + 1

B_max_sum = 0
if (minus_cnt % 2 == 0) or (min_abs_val == 0):
    B_max_sum = abs_sum
else:
    B_max_sum = abs_sum - min_abs_val * 2

print(B_max_sum)