Buggy python submission (verdict: Runtime Error):

N = int(input())
An = list(map(int, input().split()[0:N]))

An_pos = [ a for a in An if a >= 0]
An_neg = [ a for a in An if a < 0]

ans = sum(An_pos) - sum(An_neg)

if len(An_neg) % 2 == 1:
    min_abs = min(min(An_pos), -max(An_neg))
    ans -= 2 * min_abs
    pass

print(ans)


Fixed submission:
from itertools import chain

N = int(input())
An = list(map(int, input().split()[0:N]))

An_pos = [ a for a in An if a >= 0]
An_neg = [ -a for a in An if a < 0]

ans = sum(An_pos) + sum(An_neg)

if len(An_neg) % 2 == 1:
    ans -= 2 * min(chain(An_pos, An_neg))
    pass

print(ans)

Buggy python submission (verdict: Runtime Error):
import sys
from bisect import insort_left
from collections import *

N = int(input())
An = list(map(int, input().split()))[0:N]

An_pos = [ a for a in An if a >= 0]
An_neg = [ a for a in An if a < 0]

if len(An_neg) % 2 == 0:
    print(sum(An_pos) - sum(An_neg))
    sys.exit(0)
    pass

min_neg = min(min(An_pos), -max(An_neg))
print(sum(An_pos) - sum(An_neg) - 2*min_neg)


Fixed submission:
from itertools import chain

N = int(input())
An = list(map(int, input().split()[0:N]))

An_pos = [ a for a in An if a >= 0]
An_neg = [ -a for a in An if a < 0]

ans = sum(An_pos) + sum(An_neg)

if len(An_neg) % 2 == 1:
    ans -= 2 * min(chain(An_pos, An_neg))
    pass

print(ans)

Buggy python submission (verdict: Runtime Error):
import sys
from bisect import insort_left
from collections import *

N = int(input())
An = list(map(int, input().split()))[0:N]

An_sorted_pos = deque(sorted([ a for a in An if a > 0]))
An_sorted_neg = deque(sorted([ a for a in An if a < 0]))

if len(An_sorted_neg) % 2 == 0:
    print(sum(An_sorted_pos) - sum(An_sorted_neg))
    sys.exit(0)
    pass

min_neg = min(min(An_sorted_pos), -max(An_sorted_neg))

print(sum(An_sorted_pos) - sum(An_sorted_neg) - 2*min_neg)


Fixed submission:
from itertools import chain

N = int(input())
An = list(map(int, input().split()[0:N]))

An_pos = [ a for a in An if a >= 0]
An_neg = [ -a for a in An if a < 0]

ans = sum(An_pos) + sum(An_neg)

if len(An_neg) % 2 == 1:
    ans -= 2 * min(chain(An_pos, An_neg))
    pass

print(ans)

Buggy python submission (verdict: Runtime Error):
import sys
from bisect import insort_left
from collections import *

N = int(input())
An = list(map(int, input().split()))

An_sorted_pos = deque(sorted([ a for a in An if a > 0]))
An_sorted_neg = deque(sorted([ a for a in An if a < 0]))
zero_exists = not all([ a != 0 for a in An ])

if zero_exists:
    print(sum(An_sorted_pos) - sum(An_sorted_neg))
    sys.exit(0)
    pass

if len(An_sorted_neg) == 0:
    print(sum(An_sorted_pos))
    sys.exit(0)
    pass

if len(An_sorted_pos) == 0:
    if len(An_sorted_neg) % 2 == 0:
        print(-sum(An_sorted_neg))
    else:
        print(-sum(An_sorted_neg)+max(An_sorted_neg))
        pass
    sys.exit(0)
    pass

while An_sorted_pos[0] < -An_sorted_neg[0]:
    pos = An_sorted_pos.popleft()
    neg = An_sorted_neg.popleft()
    idx_pos = insort_left(An_sorted_pos, -neg)
    idx_neg = insort_left(An_sorted_neg, -pos)
    pass

print(sum(An_sorted_pos) + sum(An_sorted_neg))



Fixed submission:
from itertools import chain

N = int(input())
An = list(map(int, input().split()[0:N]))

An_pos = [ a for a in An if a >= 0]
An_neg = [ -a for a in An if a < 0]

ans = sum(An_pos) + sum(An_neg)

if len(An_neg) % 2 == 1:
    ans -= 2 * min(chain(An_pos, An_neg))
    pass

print(ans)