Problem:
 Score : 400 points    Problem Statement There are N integers, A_1, A_2, ..., A_N , arranged in a row in this order.  You can perform the following operation on this integer sequence any number of times:  Operation : Choose an integer i satisfying 1 \leq i \leq N-1 . Multiply both A_i and A_{i+1} by -1 .  Let B_1, B_2, ..., B_N be the integer sequence after your operations.  Find the maximum possible value of B_1 + B_2 + ... + B_N .      Constraints  All values in input are integers.  2 \leq N \leq 10^5  -10^9 \leq A_i \leq 10^9         Input Input is given from Standard Input in the following format:  N  A_1  A_2  ...  A_N       Output Print the maximum possible value of B_1 + B_2 + ... + B_N .        Sample Input 1 3
-10 5 -4      Sample Output 1 19  If we perform the operation as follows:   Choose 1 as i , which changes the sequence to 10, -5, -4 .  Choose 2 as i , which changes the sequence to 10, 5, 4 .   we have B_1 = 10, B_2 = 5, B_3 = 4 . The sum here, B_1 + B_2 + B_3 = 10 + 5 + 4 = 19 , is the maximum possible result.       Sample Input 2 5
10 -4 -8 -11 3      Sample Output 2 30       Sample Input 3 11
-1000000000 1000000000 -1000000000 1000000000 -1000000000 0 1000000000 -1000000000 1000000000 -1000000000 1000000000      Sample Output 3 10000000000  The output may not fit into a 32 -bit integer type.

Solution (Python):
import sys
input = sys.stdin.readline
ri = lambda: int(input())


rl = lambda: map(int,input().split())
rr = lambda N: [list(l) for l in zip(*[rl() for _ in range(N)])]
YN = lambda b: print('YES') if b else print('NO')
yn = lambda b: print('Yes') if b else print('No')
OE = lambda x: print('Odd') if x%2 else print('Even')
INF = 10**18
MOD = 10**9+7

N=ri()
A=list(rl())
cnt = [0]*3
ans = 0
sei = []
for a in A:
    sei.append(abs(a))
    ans += abs(a)
    if a > 0:
        cnt[0] += 1
    elif a == 0:
        cnt[1] += 1
    elif a < 0:
        cnt[2] += 1

if cnt[1] > 0 or cnt[2]%2 == 0:
    None
else:
    ans -= 2 * min(sei)

print(ans)

Solution (Python):
n = int(input())
data = list(map(int, input().split()))
count = 0
for i in range(n):
    if data[i] < 0:
        count += 1
    data[i] = abs(data[i])
if count % 2 == 0:
    print(sum(data))
else:
    print(sum(data) - min(data) * 2)

Solution (Python):
N = int(input())
A = map(int, input().split())
minus_count = 0
total = 0
minimum = 999999999999999999

for a in A:
	total += abs(a)
	if abs(a) < minimum:
		minimum = abs(a)
	if a < 0:
		minus_count += 1
			
if minus_count % 2 == 0:
	print(total)
else:
	print(total - 2 * minimum)

Solution (Python):
n = int(input())

a = list(map(int, input().split()))




cnt_minus = sum([1 if v < 0 else 0 for v in a])

list_abs = list(map(abs, a))
sum_abs = sum(list_abs)
min_abs = min(list_abs)

if cnt_minus % 2 == 0:
    ans = sum_abs
else:
    ans = sum_abs - 2*min_abs

print(ans)

Solution (Python):
N = int(input())
A = list(map(int,input().split()))

neg = 0
for a in A:
    if a<0:
        neg+=1
        
A = [abs(a) for a in A]        
A.sort()

if neg%2==1:
    A[0] = -1*A[0]

print(sum(A))

Solution (Python):
n = int(input())
A = list(map(int, input().split()))
L = [0 for i in range(n)]

for i in range(n):
    if A[i] < 0:
        A[i] = abs(A[i])
        L[i] = L[i] + 1 

if sum(L)%2 != 0:
    B = sum(A)-min(A)*2
else:
    B = sum(A)

print(B)

Solution (Python):
from sys import stdin

N = int(stdin.readline().rstrip())
A = [int(x) for x in stdin.readline().rstrip().split()]
if 0 in A:
    print(sum([abs(x) for x in A]))
    exit()
minus = [x for x in A if x < 0]
if len(minus) % 2 == 0:
    print(sum([abs(x) for x in A]))
else:
    absolute = sorted([abs(x) for x in A])
    print(sum(absolute) - 2 * absolute[0])

Solution (Python):
N = int(input())
A = input().split()
A = [int(x) for x in A]
b = []
answer = 0
count = 0
for i in range(N):
  if A[i] < 0:
    count = count + 1
  b.append(int(abs(A[i])))
  answer = answer + b[i] 
b.sort()
b.reverse()
if count % 2 == 1:
  answer = 0
  for j in range(N-1):
    answer = answer + b[j]
  answer = answer - b[j+1]
print(answer)

Solution (Python):
N = int(input())
A = list(map(int, input().split()))

count = 0
for a in A:
	count += (a < 0)

a = sorted(map(abs, A))

if not count % 2:
	print(sum(a))
else:
	print(sum(a[1:]) - a[0])

Solution (Python):
def larger(x, y):
	if x > y: return x
	return y

N = int(input())
A = list(map(int, input().split()))
dp1 = [A[0], -A[1]-A[0]] 
dp2 = [A[0], A[1]+A[0]] 
for i in range(2, N):
	newdp1 = larger(dp1[i-1]+2*A[i-1], dp2[i-1]-2*A[i-1]) - A[i]
	newdp2 = larger(dp1[i-1], dp2[i-1]) + A[i]
	dp1.append(newdp1)
	dp2.append(newdp2)
print(larger(dp1[N-1], dp2[N-1]))

Solution (Python):
n=int(input())
al=list(map(int,input().split()))
ans=0
z=True
x=0
m=10**10
for a in al:
    ans+=abs(a)
    z=True if a==0 else False
    x+=1 if a<0 else 0
    m=min(m,abs(a))
if z or x%2==0:
    print(ans)
else:
    print(ans-m*2)

Solution (Python):
N=int(input())
list1=list(map(int,input().split()))
dp=[[0,-2**32]]+[[0,0] for i in range(N)]
for i in range(0,N):
    dp[i+1][0]=max(dp[i][0]+list1[i],dp[i][1]-list1[i])
    dp[i+1][1]=max(dp[i][0]-list1[i],dp[i][1]+list1[i])
print(dp[N][0])

Solution (Python):
n = int(input())
li = list(map(int,input().split()))
m = 0
for i in range(n):
  if li[i] < 0:
    li[i] *= -1
    m += 1
if m%2 ==0:
  print(sum(li))
else:
  print(sum(li)-2*min(li))

Solution (Python):
n = int(input())
A = list(map(int, input().split()))
mina = 10**9
minus = 0
sumA = 0
for a in A:
    if a < 0:
        minus += 1
        a = -a
    sumA += a
    mina = min(a, mina)
if minus % 2 == 1:
    sumA -= 2 * mina
print(sumA)

Solution (Python):
N=int(input())
A=list(map(int,input().split()))

Aodd=[]
Aeven=[]
sumodd=0
sumeven=0
for i in range(N):
    if i%2==0:
        Aeven.append(A[i])
        if A[i]<0:
            sumeven+=1
    else:
        Aodd.append(A[i])
        if A[i]<0:
            sumodd+=1
if sumeven%2==sumodd%2:
    ans=sum(map(abs,A))
else:
    ans=sum(map(abs,A))-min(map(abs,A))*2
print(ans)

Solution (Python):
n = int(input())
A = map(int, input().split())
count = 0
B = []
for i in A:
    if(i<0):
        count += 1
    B.append(abs(i))
if(count % 2 == 0):
    print(sum(B))
else:
    print(sum(B) - 2*min(B))

Solution (Python):
n = int(input())
nums = list(map(int, input().split()))

count = 0
for num in nums:
    if num < 0:
        count = count + 1

mode = count % 2 == 1
sumVal = 0
if mode == False:
    for num in nums:
        sumVal = sumVal + abs(num)
else:
    minVal = None
    for num in nums:
        sumVal = sumVal + abs(num)
        if minVal == None or minVal > abs(num):
            minVal = abs(num)
    sumVal = sumVal - (minVal * 2)
print(sumVal)

Solution (Python):
n = int(input())
nums = list(map(int, input().split()))

count = 0
for num in nums:
    if num < 0:
        count = count + 1

mode = count % 2 == 1
sumVal = 0
if mode == False:
    for num in nums:
        sumVal = sumVal + abs(num)
else:
    minVal = None
    for num in nums:
        sumVal = sumVal + abs(num)
        if minVal == None or minVal > abs(num):
            minVal = abs(num)
    sumVal = sumVal - (minVal * 2)
print(sumVal)

Solution (Python):
n = int(input())
A = list(map(int, input().split()))
mina = abs(A[0])
minus = 0
sumA = 0
for a in A:
    if a < 0:
        minus += 1
        a = -a
    sumA += a
    mina = min(a, mina)
if minus % 2 == 1:
    sumA -= 2 * mina
print(sumA)

Solution (Python):
from math import fabs

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

fu_count = 0
for i in range(N):
    if A[i] < 0:
        fu_count += 1

goukei = sum(fabs(a) for a in A)

if fu_count % 2 == 1:
    goukei -= 2 * min(fabs(a) for a in A)
print(int(goukei))

Solution (Python):
N = int(input())
List = list(map(int, input().split()))

if (List.count(0)!=0)|((sum(x<0 for x in List)%2==0)):
    print(sum([abs(List[i]) for i in range(N)]))

else:
    nList = [abs(List[i]) for i in range(N)]
    print(sum(nList)-2*min(nList))

Solution (Python):
N = int(input())
A = list(map(int, input().split()))

negative_count = 0
for a in A:
    if a < 0:
        negative_count += 1

A_positive = [abs(a) for a in A]

if negative_count % 2 == 0:
    
    print(sum(A_positive))
else:
    
    print(sum(A_positive) - min(A_positive) * 2)

Solution (Python):
N = int(input())
A = list(map(int,input().split()))

B = [abs(A[i]) for i in range(N)]
A.sort()
B.sort()
count=0
for i in range(N):
    if A[i]<0:
        count+=1

if count%2==0:
    print(sum(B))
else:
    print(sum(B[1:])-B[0])

Solution (Python):

n = int(input())
a = list(map(int, input().split()))

count = 0
for i in range(n):
    if a[i] < 0:
        a[i] = -a[i]
        count += 1

ans = sum(a)
if count % 2 == 0:
    print(ans)
else:
    print(ans - min(a) * 2)

Solution (Python):

n = int(input())
a = list(map(int, input().split()))

ans = 0
count = 0
for i in range(n):
    if a[i] < 0:
        a[i] = -a[i]
        count += 1
    ans += a[i]

if count % 2 == 0:
    print(ans)
else:
    print(ans - min(a) * 2)

Solution (Python):

n = int(input())
a = list(map(int, input().split()))

ans = 0
count = 0
for i in range(n):
    if a[i] < 0:
        a[i] = -a[i]
        count += 1

ans = sum(a)
if count % 2 == 0:
    print(ans)
else:
    print(ans - min(a) * 2)

Solution (Python):
N=int(input())
LA=list(map(int,input().split()))

Minus=0
Zero=0
L_absolute=[]

for i in LA:
    if i<0:
        L_absolute.append(i*(-1))
        Minus+=1
    elif i==0:
        Zero=1
    else:
        L_absolute.append(i)
        
L_absolute.sort()

if Zero==1:
    ans=sum(L_absolute)
elif Minus%2==1:
    ans=sum(L_absolute)-2*L_absolute[0]
else:
    ans=sum(L_absolute)
    
print(ans)

Solution (Python):
N=int(input())
ans = 0
min_chk = 10**10
minus_chk = 0
for i in input().split():
    i = int(i)
    if i < 0 :
        minus_chk += 1
    num = abs(i)
    min_chk = min(num,min_chk)
    ans += num
if min_chk != 0:
    if minus_chk%2 == 1:
        print(ans-2*min_chk)
    else:
        print(ans)
else:
    print(ans)

Solution (Python):
N=int(input())
A=list(map(int,input().split()))
A.sort()
idx=N
for i in range(N):
    if A[i]>0:
        idx=i
        break
if idx==0:
    print(sum(A))
elif idx==N:
    print(sum(A[(N//2)*2:])-sum(A[:(N//2)*2]))
else:
    x=sum(A[(idx//2)*2:])-sum(A[:(idx//2)*2])
    y=sum(A[((idx+1)//2)*2:])-sum(A[:((idx+1)//2)*2])
    z=sum(A[(1+idx//2)*2:])-sum(A[:(1+idx//2)*2])
    print(max(x,y,z))

Solution (Python):
N=int(input())
A=list(map(int,input().split()))
b=0
ans=0
m=abs(A[0])
for a in A:
    ans+=abs(a)
    m=min(m,abs(a))
    if a<0:
        b+=1

if b%2==0:
    print(ans)
else:
    print(ans-m*2)

Solution (Python):
N = int(input())
A = list(map(int, input().split()))
Amin = 10**9
ans = 0
counter = 0
for i in range(N):
  if(A[i] < 0):
    counter = counter + 1
  a = abs(A[i])
  ans += a
  Amin = min(a, Amin)
    
if(counter%2 == 1):
    ans -= 2*Amin
  
print(ans)

Solution (Python):
n=int(input())
al=list(map(int,input().split()))
nummin=sum(a<0 for a in al)
asum=0
amin=10**9
for a in al:
  a=abs(a)
  asum+=a
  amin=min(amin,a)
if nummin%2==1:
  ans=asum-2*amin
else:
  ans=asum
print(ans)

Solution (Python):
n = int(input())
a = list(map(int, input().split()))
count_t = list(filter(lambda x: x < 0, a))
count = len(count_t)
s = []
for i in a:
    if i < 0:
        s.append(i * -1)
    else:
        s.append(i)

if count % 2 == 0 or a.count(0) > 0:
    print(sum(s))
else:
    print(sum(s) - min(s) * 2)

Solution (Python):


from functools import reduce

def positivesum(lists):
	for i in range(len(lists)):
		if lists[i]<0:
			lists[i]=lists[i]*(-1)
	return(sum(lists))
	

n=int(input())
alist=list(map(int,input().split()))


count=0
for i in range(n):
	if alist[i]<0:
		count+=1


if count==n and count%2==1:
	print(-sum(alist)+2*max(alist))

elif count%2==0:
	print(positivesum(alist))
else:
	alist.sort()
	x=max(alist[count-1],-alist[count])
	print(positivesum(alist)+x*2)

Solution (Python):

def main():
    _ = input()
    A = list(map(int, input().split()))
    A_list = []
    count = 0

    for a in A:
        if a < 0:
            count += 1
            A_list.append(a * -1)
        else:
            A_list.append(a)
    if count % 2 == 0:
        print(sum(A_list))
    else:
        print(sum(A_list)-min(A_list) * 2)


if __name__ == "__main__":
    main()

Solution (Python):

def main():
    _ = input()
    A = list(map(int, input().split()))
    A_list = []
    count = 0
    for a in A:
        if a < 0:
            count += 1
            A_list.append(a * -1)
        else:
            A_list.append(a)
    if count % 2 == 0:
        print(sum(A_list))
    else:
        print(sum(A_list)-min(A_list) * 2)


if __name__ == "__main__":
    main()

Solution (Python):
n = int(input())
A = sorted(map(int, input().split()), key=lambda x : abs(x))
count = sum(x < 0 for x in A)
if count % 2 == 0:
    print(sum(abs(x) for x in A))
else:
    print(-abs(A[0]) + sum(abs(x) for x in A[1:]))

Solution (Python):
N = int(input())
A = list(map(int,input().split()))

sign = 1
for i in range(N):
    if A[i] < 0:
        sign *= -1
    elif A[i] == 0:
        sign *= 0

A = [abs(a) for a in A]
A.sort()

if sign < 0:
    print(sum(A)-2*A[0])
else:
    print(sum(A))

Solution (Python):
import sys
stdin = sys.stdin

sys.setrecursionlimit(10 ** 7)

def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x) - 1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())


n = ni()
a = list(li())

absmin = 10**18
mnscnt = 0
ans = 0

for ai in a:
    if ai < 0:
        mnscnt += 1

    absmin = min(absmin, abs(ai))
    ans += abs(ai)

if mnscnt % 2:
    print(ans - 2*absmin)
else:
    print(ans)

Solution (Python):
from functools import reduce
N = int(input())
A = list(map(int,input().split()))
B = list(map(lambda x: x+0.5, A))
C = reduce(lambda a, b: a*b, B)
D = sorted(list(map(abs, A)))
if C < 0:
	print(sum(D)-2*D[0])
else:
	print(sum(D))

Solution (Python):
N=int(input())
A=list(map(int,input().split()))
print(sum(map(abs,A))-2*min(map(abs,A))*(sum([1 for i in A if i<0])%2))

Solution (Python):
N=int(input())
A=list(map(int,input().split()))
print(sum(map(abs,A))-2*min(map(abs,A))*(sum([1 for i in A if i<0])%2))

Solution (Python):
import sys
input = sys.stdin.readline
'''
allinputs = iter(input().splitlines())
input = lambda : next(allinputs)


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

sum_abs = 0
min_abs = 10 ** (9)
count_minus = 0
for i in range(N):
	if A[i] < 0:
		count_minus += 1
		sum_abs -= A[i]
		if -A[i] < min_abs:
			min_abs = -A[i]
	else:
		sum_abs += A[i]
		if A[i] < min_abs:
			min_abs = A[i]

if count_minus % 2 == 0:
	print(sum_abs)
else:
	print(sum_abs - 2 * min_abs)

Solution (Python):
n = int(input())
a = list(map(int, input().split()))
if len([x for x in a if x<0])%2 == 0:
	print(sum([abs(x) for x in a]))
else:
	print(sum([abs(x) for x in a]) - 2*min([abs(x) for x in a]))

Solution (Python):
N = int(input())

a = [int(i) for i in input().split()]

count=0
ans=0

for i in range(N):
    if a[i]<0:
        count+=1
        a[i]=abs(a[i])

if count%2==0:
    ans=sum(a)

else:
    a.sort()
    ans=sum(a)-a[0]*2

print(ans)

Solution (Python):
N = int(input())

a = [int(i) for i in input().split()]

count=0
ans=0

for i in range(N):
    if a[i]<0:
        count+=1
    a[i]=abs(a[i])

if count%2==0:
    ans=sum(a)

else:
    a.sort()
    ans=sum(a)-a[0]*2

print(ans)

Solution (Python):
N = int(input())
A = list(map(int,input().split()))

minus = 1
for i,a in enumerate(A) :
    if a < 0 :
        minus *= -1
        A[i] = -a

ans = sum(A)

A.sort()

if minus == -1 :
    ans -= A[0] * 2

print(ans)

Solution (Python):
import numpy as np

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

A = np.array(A)
idx_minabs = np.argmin(np.abs(A))
n_minus = np.sum(A < 0) - (A[idx_minabs] < 0)

ans = np.sum(np.abs(A)) - np.abs(A[idx_minabs]) + (2*((n_minus+1)%2)-1)*A[idx_minabs]

print(ans)

Solution (Python):

import numpy as np


n = int(raw_input())

A_list = map(int,raw_input().split())

minus_sum = sum(x<0 for x in A_list)

arr_A = np.array(A_list)
abs_arr = np.abs(arr_A)
ABS_list = abs_arr.tolist()


_min = min(ABS_list)
min_id = [i for i, x in enumerate(ABS_list) if x == _min]

if(minus_sum%2 == 0):
	print sum(ABS_list)
else:
	print sum(ABS_list)-ABS_list[min_id[0]]-ABS_list[min_id[0]]

Solution (Python):

import numpy as np

n = int(raw_input())

A_list = map(int, raw_input().split())
A_list_np = np.array(A_list)

minus_sum = np.sum(A_list_np < 0)

if(minus_sum%2 == 0):
	print np.sum(np.abs(A_list_np))
else:
	print np.sum(np.abs(A_list_np))-np.min(np.abs(A_list_np)) * 2

Solution (Python):
n = int(input())
A = list(map(int, input().split()))
A.sort()
eo = False 
suma = sum(A)
lta = 10**10
for j in range(n):
    i = A[j]
    if i <= 0: 
        if j == n - 1 and not eo: break
        eo ^= True
        lta = i
        suma += 2*(-i)
        
    else: 
        if lta == 10**10: break
        if eo: 
            if abs(i) > abs(lta):
                suma += lta*2
            else:
                suma += 2*(-i)
         
        break
print(suma)

Solution (Python):
n = int(input())
a = list(map(int, input().split() ))


negative_values = list(filter(lambda x:x<0 , a) )

num_negative = len(negative_values)

if num_negative % 2 == 0 :
	ans = sum(list(map(abs, a)))
	print(ans)
else:
	
	abs_array = list(map(abs, a))
	ans = sum(abs_array) - 2 * min(abs_array)
	print(ans)

Solution (Python):
N = int(input())

A = sorted([int(x) for x in input().split()])


B = [-a for a in A if a < 0]
D = [a for a in A if a >= 0]

if len(B) % 2 == 1:
    B[-1] = -B[-1]
    if D and -B[-1] > D[0]:
        B[-1] = -B[-1]
        D[0] = -D[0]

print(sum(B)+sum(D))

Solution (Python):
N = int(input())

A = [int(i) for i in input().split()]

ans = 0
A_min = 10 ** 10
if len([a for a in A if a < 0]) % 2 == 0:
    for a in A:
        ans += abs(a)
    print(ans)
else:
    for a in A:
        ans += abs(a)
        A_min = min(abs(a), A_min)
    print(ans - 2 * A_min)

Solution (Python):
N = int(input())
A = list(map(int, input().split()))

count = 0
for i in range(N):
    if A[i] < 0:
        count += 1

ans = 0
MIN = 10 ** 9
if count % 2:
    for i in range(N):
        ans += abs(A[i])
        MIN = min(abs(A[i]), MIN)
    ans = ans - 2 * MIN
else:
    for i in range(N):
        ans += abs(A[i])

print(ans)

Solution (Python):


n=input()
a=list(map(int,input().split()))
b=[abs(x)for x in a]


print(sum(b)-2*min(b)if sum(x<0 for x in a)%2 else sum(b))

Solution (Python):

















import math
import copy
from collections import defaultdict
from collections import Counter
from collections import deque

from itertools import product

from itertools import permutations

from itertools import combinations
from bisect import bisect_left, bisect_right


def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W


dy = [0, -1, 0, 1]
dx = [1, 0, -1, 0]

def i_inpl(): return int(input())
def s_inpl(): return map(int,input().split())
def l_inpl(): return list(map(int, input().split()))
INF = float("inf")






N = i_inpl()
A = l_inpl()



dp = [[-INF] * 2 for _ in range(N+1)]
dp[0][0] = 0

for i in range(N):
    dp[i+1][0] = max(dp[i][0] + A[i], dp[i][1] - A[i])
    dp[i+1][1] = max(dp[i][0] - A[i], dp[i][1] + A[i])

print(dp[N][0])

Solution (Python):
import numpy as np
from collections import defaultdict
from functools import reduce

n = int(input())
A = list(map(int, input().split()))

S = reduce(lambda x, y: abs(x)+abs(y), A)


if len(list(filter(lambda x: x<0, A)))%2 == 0:
    print(S)
else:
    print(S - 2*min(abs(x) for x in A))

Solution (Python):
N = int(input())
A = list(map(int, input().split()))
abs_A = [abs(i) for i in A]
neg_A = [i for i in A if i < 0]

if len(neg_A) % 2 == 0:
	ans = sum(abs_A)
else:
	min = min(abs_A)
	ans = sum(abs_A) - 2 * min

print(ans)

Solution (Python):
n=int(input())
a=list(map(int, input().split()))
abs_a = []

min_a = 10**9
num_minus = 0
for i in range(n):
    abs_ai = abs(a[i])
    if a[i]<0:
        num_minus+=1
    if abs_ai<min_a:
        min_a=abs(abs_ai)
    abs_a.append(abs_ai)
ans=sum(abs_a)
if num_minus%2!=0:
    ans = ans-2*min_a
print(ans)

Solution (Python):
n = int(input())
a = list(map(int,input().split()))
mi = 0
for i in range(n):
  if a[i] < 0:
    mi+=1
  a[i]= abs(a[i])
if mi %2 == 1:
  print(sum(a)-2*min(a))
else:
  print(sum(a))

Solution (Python):
n=int(input())
a=[int(i) for i in input().split()]

abs_min=abs(a[0])
abs_sum=0
cnt=0
for val in a:
	if val<0:
		cnt+=1
	abs_sum+=abs(val)
	abs_min=min([abs_min,abs(val)])

if cnt%2==0:
	print(abs_sum)
else:
	print(abs_sum-2*abs_min)

Solution (Python):
N = int(input())
A = list(map(int,input().split(' ')))
ABS_LIST = list(map(abs,A))
ABS_SUM = sum(ABS_LIST)
if len([x for x in A if x < 0])%2 != 0:
    print(ABS_SUM-min(ABS_LIST)*2)
else:
    print(ABS_SUM)

Solution (Python):
N = int(input())
A = list(map(int,input().split(' ')))
sum = 0
min = 1000000000
minus = 0
for n in range(N):
    n_abs = abs(A[n])
    sum += n_abs
    if min > n_abs:
        min = n_abs
    if A[n] < 0:
        minus += 1
if minus%2 != 0:
    sum -= 2*min
print(sum)

Solution (Python):

num_count = int(input())


nums_list = list(map(int, input().split()))

max_num = 0
zero_count = 0
minus_count = 0

for num in nums_list:
    max_num += abs(num)

    if num == 0:
        zero_count += 1
    if num < 0:
        minus_count += 1

if zero_count == 0 and minus_count % 2 != 0:
    max_num -= min(list(map(abs, nums_list))) * 2

print(max_num)

Solution (Python):
n = int(input())
A = list(map(int, input().split()))

abs_list = list(map(abs, A))
abs = sum(abs_list)
x = len([i for i in A if i < 0]) 

if x % 2 ==0:
  print(abs)
 
else:
  min_abs = min(abs_list)
  print(abs - 2*min_abs)

Solution (Python):
n = int(input())
a = map(int, input().split())
ans = 0
c = 0
m = 10 ** 9

for i in a:
    if i > 0:
        ans += i
        if m > i:
            m = i
    else:
        ans -= i
        c += 1
        if m > -i:
            m = -i

if c % 2 == 1:
    ans -= 2 * m

print(ans)

Solution (Python):
n = int(input())
l = list(map(int,input().split()))
k = 0
p = 0
for i in l:
    if i < 0:
        k += 1

for i in l:
    p += abs(i)
if k % 2 ==0:
    print(p)
else:
    print(p-(2*min(list(map(abs,l)))))

Solution (Python):
N = int(input())
A = list(map(int, input().split()))

b = []

c = 0
for a in A:
    if a < 0:
        c += 1
    b.append(abs(a))

if c % 2 == 0:
    print(sum(b))
else:
    print(sum(b) - 2 *min(b))

Solution (Python):
N = int(input())
A = list(map(int, input().split()))

num_of_minus = sum([a < 0 for a in A])
abs_A = [abs(a) for a in A]
ans = sum(abs_A)

if num_of_minus % 2 == 0:
  print(ans)
else:
  print(ans - 2 * min(abs_A))

Solution (Python):
import numpy as np

n = int(input())
a = list(map(int, input().split()))
na = np.array(a)
total = 0

wh = len([i for i in a if i <= 0])

if wh % 2 == 0 :
    print(sum(np.abs(na)))
else :
    m = min(np.abs(na))
    print(sum(np.abs(na)) - 2*m)

Solution (Python):
n = int(input())
arr = list(map(int, input().split()))
abs_arr = list(map(abs, arr))

if len(list(filter(lambda i: i < 0, arr))) % 2 == 1:
    print(sum(abs_arr) - min(abs_arr) * 2)
else:
    print(sum(abs_arr))

Solution (Python):





n = int(input())
a = list(map(int,input().split()))

minus = 0
a_min = abs(a[0])
a_sum = 0

for x in a:
  if x < 0:
    minus += 1
    x = -x
  if x < a_min:
    a_min = x
  a_sum += x

if minus % 2 == 0:
  print(a_sum)
else:
  print(a_sum - 2 * a_min)

Solution (Python):
N = int(input())
A = list(map(int, input().split()))

minus_num = [i for i in A if i < 0]
abs_num = map(abs, A)
min_num = min(abs_num)

for i in range(N):
    if A[i] < 0:
        A[i] = -A[i]

if len(minus_num) % 2 != 0:
    A.append(min_num * -2)

print(sum(A))

Solution (Python):
N = int(input())
A = [int(x) for x in input().split()]
 
if 0 in A:
    out = 0
    for i in A:
        out += abs(i)
    print(out)
else:
    count = 0
    for i in A:
        if i < 0:
            count += 1
    
    if count%2 == 0:
        out = 0
        for i in A:
            out += abs(i)
        print(out)
    else:
        count = 10 ** 9
        for i in A:
            if abs(i) < count:
                count = abs(i)
        
        out = 0
        for i in A:
            out += abs(i)
        out = out - count*2
        
        print(out)

Solution (Python):
n=int(input())
a=[int(i) for i in input().split()]

ans = 0


nns = len([x for x in a if x < 0])

ans = sum([abs(x) for x in a])

if nns%2 != 0:
  ans -= 2*min(abs(i) for i in a)
  
print(ans)

Solution (Python):
n = int(input())
a = list(map(int,input().split()))
dp_table = [0, -10 ** 10]
temp = [0,0]
for i in range(n):
    temp[0] = dp_table[0]
    temp[1] = dp_table[1]
    dp_table[0] = max(temp[0]+a[i],temp[1]-a[i])
    dp_table[1] = max(temp[0]-a[i],temp[1]+a[i])
    
print(dp_table[0])

Solution (Python):
n=int(input())
a=list(map(int,input().split()))
b=[abs(i) for i in a]
m=len([i for i in a if i<0])
M=len([i for i in a if i>0])
ans=0
if (m%2==1 and M%2==0) or (m%2==M%2==1):
    ans=sum(b)-2*min(b)
else:
    ans=sum(b)
print(ans)

Solution (Python):
N=int(input())
A=list(map(int,input().split()))
n=0
for i in range(len(A)):
    if A[i]<0:
        n+=1
if n%2==0:
    ans=0
    for i in range(len(A)):
        ans+=abs(A[i])
if n%2==1:
    B=A
    for i in range(len(A)):
        B[i]=abs(A[i])
    minn=min(B)
    ans=0
    for i in range(len(A)):
        ans+=B[i]
    ans-=2*minn
print(ans)

Solution (Python):
N = int(input())
A = list(map(int, input().split()))
dp = [0, -10**20]
tmp = [0, 0]

for i in range(N):
    tmp[0] = max(dp[0] + A[i], dp[1] - A[i])
    tmp[1] = max(dp[0] - A[i], dp[1] + A[i])
    dp[0], dp[1] = tmp[0], tmp[1]
print(dp[0])

Solution (Python):
N = int(input())
A = list(map(int, input().split()))
dp = [[0,0] for i in range(N+1)]
dp[0][1] = -10**20

for i in range(N):
    dp[i+1][0] = max(dp[i][0] + A[i], dp[i][1] - A[i])
    dp[i+1][1] = max(dp[i][0] - A[i], dp[i][1] + A[i])

print(dp[-1][0])

Solution (Python):
from sys import stdin


def main():
    _ = int(stdin.readline().rstrip())
    As = [int(x) for x in stdin.readline().rstrip().split()]
    mcount = len([x for x in As if x < 0])
    if mcount % 2 == 0:
        print(sum([abs(x) for x in As]))
    else:
        min_ = min([abs(x) for x in As])
        sum_ = sum([abs(x) for x in As])
        print(sum_ - (min_ * 2))


if __name__ == "__main__":
    main()

Solution (Python):
def sub():
    N, As = [input() for _ in range(2)]
    N = int(N)
    As = [int(e) for e in As.split(" ")]

    dp = {(-1, 0): 0, (-1, 1): -1e10}
    for i in range(0, N):
        dp[(i, 0)] = max(dp[(i - 1, 0)] + As[i], dp[(i - 1, 1)] - As[i])
        dp[(i, 1)] = max(dp[(i - 1, 0)] - As[i], dp[(i - 1, 1)] + As[i])
    print("{}".format(dp[(N - 1, 0)]))


sub()

Solution (Python):
N = int(input())
A = list(map(int, input().split()))

num_of_minus = sum([a < 0 for a in A])
abs_A = [abs(a) for a in A]

ans = sum(abs_A)

if num_of_minus % 2 == 0:
    print(ans)
else:
    print(ans - 2 * min(abs_A))

Solution (Python):
N=int(input())
A=list(map(int,input().split()))
pbox=[]
nbox=[]
if 0 in A:
  count=0
  for i in A:
    count += abs(i)
  print(count)
else:
  for i in A:
    if i > 0:
      pbox.append(i)
    else:
      nbox.append(i)
  if len(nbox)%2==0:
    count=0
    for i in A:
      count += abs(i)
    print(count)
  else:
    box=[]
    for i in A:
      box.append(abs(i))
    mi=min(box)
    count=0
    for i in A:
      count += abs(i)
    print(count-2*mi)

Solution (Python):
N = int(input())
A = list(map(int, input().split()))

i = 0
j = 0
total = 0
count = 0
min = abs(A[0])

for i in range(N):
    total += abs(A[i])
    if A[i] < 0:
        count += 1
    if min > abs(A[i]):
        min = abs(A[i])

if count % 2 == 1:
    total = total - 2 * min

print(total)

Solution (Python):
n = int(input())
a = list(map(int, input().split()))
pbox = []
nbox = []
if 0 in a:
    count = 0
    for i in a:
        count += abs(i)
    print(count)
else:
    for i in a:
        if i > 0:
            pbox.append(i)
        else:
            nbox.append(i)
    if len(nbox) % 2 == 0:
        count = 0
        for i in a:
            count += abs(i)
        print(count)
    else:
        box = []
        for i in a:
            box.append(abs(i))
        mi = min(box)
        count = 0
        for i in a:
            count += abs(i)
        print(count - 2*mi)

Solution (Python):

n = int(input())
lst = [int(x) for x in input().split()]

func = lambda x : 1 if( x > 1) else 0 if( x == 0) else -1

signs = [func(x) for x in lst]
lst = [abs(x) for x in lst]

if(signs.count(-1)%2 == 1):
    m = min(lst)
    lst.remove(m)
    s = sum(lst) - m
    print(s)
else:
    print(sum(lst))

Solution (Python):


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

count=num=total=0
b=[]

for i in a:
    if i<0:
        count+=1
    elif i==0:
        num+=1

if count%2==0 or num>0:
    for j in a:
        total=total+abs(j)
    print(total)
else:
    for k in a:
        total=total+abs(k)
    for l in a:
        b.append(abs(l))

    print(total-2*min(b))

Solution (Python):
from functools import reduce
from operator import add

n = int(input())
lst = list(map(int, input().split()))

m = 0 
z = 0 

for i in range(n):
  if lst[i] == 0:
    z += 1
  if lst[i] < 0:
    m += 1

ans = 0
l = list(map(abs, lst))
if m%2 == 1 and z == 0:
  ans = reduce(add,l) - 2 * min(l)
else:
  ans = reduce(add,l)
print(ans)

Solution (Python):
n = int(input())
a = list(map(int, input().split()))

if sum([x<0 for x in a])%2 == 0:
    print(sum([x if x > 0 else -x for x in a]))
else:
    print(sum([x if x > 0 else -x for x in a]) - min(list(map(abs, a))) * 2)

Solution (Python):
n = int(input())
a = [int(i) for i in input().split()]

a_sum = abs(a[0])
a_min = abs(a[0])
cnt = 0
if a[0] < 0:
    cnt += 1
for i in range(n - 1):
    a_min = min(a_min, abs(a[i+1]))
    a_sum += abs(a[i+1])
    if a[i + 1] < 0:
        cnt += 1
if cnt % 2 == 0:
    print(a_sum)
else:
    print(a_sum-a_min*2)

Solution (Python):
n=int(input())
a=list(map(int,input().split()))
b=[abs(x) for x in a]
ret=0
for i in range(n):
  if a[i]!=b[i]:
    ret+=1
ans=sum(b)
if ret%2:
  ans-=2*min(b)
print(ans)

Solution (Python):
from itertools import accumulate
from math import*
from collections import deque
from collections import defaultdict
from itertools import permutations
from heapq import*
from collections import Counter
from itertools import*
from bisect import bisect_left,bisect_right
from copy import deepcopy
inf = 10**18
mod = 10**9+7
from functools import reduce
import sys
sys.setrecursionlimit(10**7)

n = int(input())
a = list(map(int,input().split()))
dp = [[0]*2 for i in range(n+1)]
dp[0][1] = -inf
for i in range(n):
    dp[i+1][0] = max(dp[i][0]+a[i],dp[i][1]-a[i])
    dp[i+1][1] = max(dp[i][0]-a[i],dp[i][1]+a[i])
print(dp[n][0])

Solution (Python):
import sys
from functools import lru_cache
sys.setrecursionlimit(10**7)
INF = 10 ** 18

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def II(): return int(sys.stdin.readline())

N = II()
A_li = LI()
N = len(A_li)

@lru_cache(maxsize=None)
def dp(i,j):
    if i == 0:
        if j == 0: return A_li[0]
        elif j == 1: return -A_li[0]
    else:
        if j == 0: return max(dp(i-1, 0) + A_li[i], dp(i-1, 1) - A_li[i])
        elif j == 1: return max(dp(i-1, 0) - A_li[i], dp(i-1, 1) + A_li[i])

print(dp(N-1,0))