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 numpy as np

def spaceinput():
    return list(map(int,input().split(" ")))
    
N=int(input())
a=np.array(spaceinput())


cnt_minus=0
cnt_zero=0
for sa in a:
    if sa==0:
        cnt_zero+=1
    if sa<0:
        cnt_minus+=1


a_abs=np.abs(a)
suma=np.sum(a_abs)


if cnt_minus%2==0 or cnt_zero>0:
    res=suma
else:
    res=suma-2*np.min(a_abs)

print(res)

Solution (Python):
n=int(input())
a=list(map(int, input().split()))
cnt=0
abs_min=10**9
abs_sum=0
for ai in a:
    if ai<0:
        cnt+=1        
    abs_min=min(abs_min, abs(ai))
    abs_sum+=abs(ai)
if cnt%2==0:
    ans=abs_sum
else:
    ans=abs_sum-abs_min*2
print(ans)

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

Solution (Python):


N = int(input())
Alist = [int(x) for x in input().split()]
Abslist = [abs(x) for x in Alist]

if 0 in Alist:
    ans = sum(Abslist)
else:
    count = 0
    for i in Alist:
        if i < 0:
            count += 1
    if count % 2 == 0:
        ans = sum(Abslist)
    else:
        ans = sum(Abslist) - 2* min(Abslist)

print(ans)

Solution (Python):
import numpy as np

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

ans = np.zeros(1, dtype=np.uint64)
even_odd = 0
mini = 1000000000

for i in A:
    if(i < 0):
        even_odd = (even_odd + 1) % 2
    ans += abs(i)
    if(mini > abs(i)):
        mini = abs(i)
        
if(even_odd == 0):
    print(ans[0])
else:
    print((ans - (mini * 2))[0])

Solution (Python):
N = int(input())
*A, = map(int, input().split())
a = 0
for i in range(N-1):
    if A[i] < 0:
        A[i] = -A[i]
        A[i+1] = -A[i+1]
    a += A[i]
if A[N-1] >= 0:
    print(a+A[N-1])
else:
    a = [abs(v) for v in A]
    a.sort()
    print(sum(a)-a[0]*2)

Solution (Python):
from collections import Counter
N=int(input())
A=list(map(int,input().split()))
judge=Counter([('0' if k==0 else '-1' if k<0 else '1') for k in A])

new_list=[i if i>=0 else -i for i in A]
if ((judge['0'] != 0) or (judge['-1'] % 2 == 0)):
    print(sum(new_list))
else:
    print(sum(new_list)-2*min(new_list))

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

num = 0
for i in range(n):
    if a[i] < 0:
        num = num + 1
if num % 2 == 0:
    ans = sum(b)
else:
    ans = sum(b) - (b[0]*2)
print(ans)

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

A = sorted(A)
sumA = sum(A)

for n in range(0, N-1, 2):
    v = A[n] + A[n+1]
    if v < 0:
        sumA = sumA - (2* v)
    else:
        break
print(sumA)

Solution (Python):
N = int(input())
A = list(map(int, input().split()))
A.sort(key=lambda a: abs(a))

minus_count = sum(a < 0 for a in A)
has_zero = (0 in A)
abs_sum = sum(abs(a) for a in A)

if has_zero or minus_count%2==0:
    print(abs_sum)
else:
    print(abs_sum - 2*abs(A[0]))

Solution (Python):
num= int (input())
nl = list ( map ( int , input ().split()))
fugo = [0 if i < 0 else 1 for i in nl]
mi = fugo.count(0)
nla =[abs(x) for x in nl]
nlsum = sum (nla)
if mi % 2 == 1 :
    minus = min(nla) * -2
    nlsum += minus
print(nlsum)

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

cnt = 0
for i in range(N):
	if A[i]<0:
		A[i] = -A[i]
		cnt = (cnt+1)%2

if 0 in A:
	print(sum(A))
elif cnt==0:
	print(sum(A))
else:
	print(sum(A)-min(A)*2)

Solution (Python):
import sys

N = int(sys.stdin.readline())

A = list(map(int, sys.stdin.readline().split()))

abstotal = 0
count_minus = 0
abs_A = []
for i in range(N):
    abstotal += abs(A[i])
    abs_A.append(abs(A[i]))
    if A[i] < 0:
        count_minus += 1

ans = abstotal
if count_minus%2 == 1:
    ans = abstotal - 2 * min(abs_A)

print(ans)

Solution (Python):
import numpy as np
N = int(input())
list1 = list(map(int, input().split()))

sum1 = 0
for i in list1:
    if(i<0):
        sum1 += 1

nl1 = np.array(list1)
np.abs(nl1)
if(sum1%2 == 0):
    a = sum(np.abs(nl1))
else:
    a = sum(np.abs(nl1))-2*min(np.abs(nl1))

print(a)

Solution (Python):
import math

N = int(input())
A = list(map(int, input().strip().split(' ')))
B = []

sum_A = abs(A[0])
min_A = abs(A[0])
mins = 1 if A[0] < 0 else 0
for i in range(1, N):
    sum_A += abs(A[i])
    min_A = min(min_A, abs(A[i]))
    if A[i] < 0:
        mins += 1 if A[i] < 0 else 0

if mins % 2 == 0:
    print(sum_A)
else:
    print(sum_A-min_A*2)

Solution (Python):
import numpy as np

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


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

if count==1 or point%2==0:
    print(sum(np.abs(A)))

else:
    A1 = np.abs(A)
    A2 = min(A1)
    print(sum(A1)-2*A2)

Solution (Python):
N = int(input())
A = [int(i) for i in input().split()]
B = [abs(i) for i in A]
for i in range(N-1):
    if(A[i]<0):
        A[i] = -A[i]
        A[i+1] = -A[i+1]
if(A[N-1]<0):
    flag = False
else:
    flag = True

if(flag):
    print(sum(A))
else:
    m = min(B)
    print(sum(B)-2*m)

Solution (Python):
N = int(input())
A = list(map(int,input().split()))
s = 1
for i in A:
  if i < 0:
    s *= -1
Aabs = list(map(abs,A))

if s == 1:
  print(sum(Aabs))
else:
  print(sum(Aabs)-2*min(Aabs))

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

Solution (Python):
N=int(input())
A=list(map(int,input().split()))
B=[]
C=[]
for i in range(N):
    if A[i]<=0:
        B.append(-A[i])
    else:
        C.append(A[i])
if len(B)%2==0:
       print(sum(B)+sum(C))
else:
        if C==[]:
            print(sum(B)+sum(C)-2*min(B))
        else:
            print(sum(B)+sum(C)-2*min(min(B),min(C)))

Solution (Python):

import sys


def parse(file):
    n = int(file.readline().strip())
    nums = map(int, file.readline().split())
    return n, nums


def main(n, nums):
    minimum_abs = 1e20
    negatives = 0
    ans = 0

    for num in nums:
        if num < 0:
            a = - num
            negatives += 1
        else:
            a = num

        if a < minimum_abs:
            minimum_abs = a
        ans += a

    if negatives % 2 == 1:
        ans -= (minimum_abs * 2)

    return ans


if __name__ == '__main__':
    print(main(*parse(sys.stdin)))

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

t = sum(x < 0 for x in s)
p = 0
p1 = abs(s[0])
q = abs(s[0])

if t % 2 == 0:
    for i in range(n):
        p += abs(s[i])
    print(p)
else:
    for i in range(n-1):
        p1 += abs(s[i+1])
        q = min(q,abs(s[i+1]))
    print(p1-q*2)

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

Solution (Python):
import math
import re

n = int(raw_input())
a = raw_input().split()

cnt = 0
minus = 0
b = []
for i in a:
    a[cnt] = int(i)
    b.append(abs(int(i)))
    if a[cnt] < 0:
        minus += 1
    cnt += 1


if minus % 2 != 0:
    mini = min(b)
else:
    mini = 0

total = 0
for i in b:
    total += abs(i)

total -= 2 * abs(mini)
print total

Solution (Python):
n = int(input())
data = list(map(int,input().split()))
nega = 0
for d in data:
  if d <= 0:
    nega += 1
    
data = sorted([abs(d) for d in data])
    
if nega % 2 == 0:
  res = sum(data)
  print(res)
  
else:
  res = sum(data[1:])
  print(res - data[0])

Solution (Python):


n = int(input())
a = list(map(int, input().split()))
a_ = [0] * n
for i in range(n):
    a_[i] = abs(a[i])

output = 0
all_plus = False
minus_kisuu = False
for i in range(n):
    if a[i] == 0:
        all_plus = True
        break
    if a[i] < 0:
        minus_kisuu = not minus_kisuu

if all_plus or not minus_kisuu:
    for i in range(n):
        output += a_[i]
else:
    for i in range(n):
        output += a_[i]
    output -= min(a_) * 2

print(output)

Solution (Python):



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

aa = list(map(lambda x: abs(x), A))
c = len(list(filter(lambda x: x < 0, A)))
s = sum(aa)
if c % 2 == 1:
    s -= min(aa) * 2
print(s)

Solution (Python):
import numpy as np
N = (int(input())+1)
A = [int(i) for i in input().split()]
B = np.abs(A)
C = 0
for i in range(N-1):
  if A[i]<0 : C+=1

C %= 2
min = min(B)

if C==0: print(sum(B))
else : print(sum(B)-min*2)

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

neg = sum(1 for a in As if a < 0)



if neg % 2 == 0:
    print(sum(absl))
else:
    print(sum(absl) - min(absl) * 2)

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

m = 10**9+1
minus_count = 0
for i in range(n):
    if a[i] < 0:
        minus_count += 1 
    if m > abs(a[i]):
        m = abs(a[i])
    a[i] = abs(a[i])
if minus_count % 2 == 0:
    print(sum(a))
else:
    print(sum(a) - m*2)

Solution (Python):
n = int(input())
a = list(map(int,input().split()))
i = 0
while i < n-1:
  if a[i] <= 0 and a[i+1] <= 0:
    a[i] = -1*a[i]
    a[i+1] = -1*a[i+1]
    i += 2
  elif a[i] > 0:
    i += 1
  elif a[i] <= 0 and a[i+1] > 0:
    a[i] = -1*a[i]
    a[i+1] = -1*a[i+1]
    i += 1
if a[n-1] < 0:
  a[n-1] = -1*a[n-1]
  print(sum(a)-2*min(a))
else:print(sum(a))

Solution (Python):
N = int(input())
A = [int(x) for x in input().split()]

cnt = 0
x = float('inf')
s = 0
for a in A:
    if a < 0:
        cnt += 1
    a = abs(a)
    x = min(x, a)
    s += a

if cnt % 2 == 0:
    print(s)
else:
    print(s - 2 * x)

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


def m():
    abs_A = [abs(a) for a in A]
    mines_cnt = 0
    for a in A:
        if a < 0:
            mines_cnt += 1
    if mines_cnt % 2 == 0:
        return sum(abs_A)
    return sum(abs_A) - min(abs_A)*2


print(m())

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

plus=0
minus=0
for i in A:
    if i<0:
        minus+=1


value=999999999999999999999999999999
for num1,i in enumerate(A):
    if abs(i)<value:
        absmin=num1
        value=abs(i)

count=0
if minus%2==0:
    for i in A:
        count+=abs(i)
else:
    for num,i in enumerate(A):
        if num==absmin:
            count+=-abs(i)
        else:
            count+=abs(i)
        

print(count)

Solution (Python):

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

l_minus = [i for i in a if i <= 0]
l_plus = [i for i in a if i > 0]

ans = 0
if len(l_minus) % 2 == 0:
    l_minus_edit = [-i for i in l_minus]
else:
    l_minus_edit = [-i for i in l_minus]
    temp = l_plus[:]
    temp.extend(l_minus_edit)
    l_minus_edit.append(-min(temp) * 2)

ans = sum(l_plus) + sum(l_minus_edit)
print(ans)

Solution (Python):
n = input()
a = list(map(int, input().split(' ')))
p = 0
z = False
ret = 0
for i in range(len(a)):
    if a[i] == 0:
        z = True
    if a[i] < 0:
        p = (p + 1) % 2
        a[i] = -a[i]
    ret = ret + a[i]
a.sort()
if z == True or p == 0:
    print(ret)
else:
    print(ret-2*a[0])

Solution (Python):
n = int(input())
a = [int(i) for i in input().split()]
b = []
count1 = 0
count2 = 0
for s in range(n):
	b.append(abs(a[s]))
	if a[s] < 0:
		count1 += 1
	elif a[s] == 0:
		count2 += 1
if count1 % 2 == 0 or count2 != 0:
	print(sum(b))
else:
	print(sum(b) - min(b)*2)

Solution (Python):


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

negative_number = len([n for n in A_list if n < 0])

A_list_abs = [abs(n) for n in A_list]
A_list_abs.sort()
total = sum(A_list_abs)

if negative_number % 2 == 0:
    print (total)
else:
    print (total - 2*A_list_abs[0])

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

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

minus = sum(x < -1 for x in a) % 2
plus = sum(abs(x) for x in a)
mina = min(absa)

if minus == 0:
  print(plus)
else:
  print(plus - mina * 2)

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

cntMinus = sum([1 for a in lstA if a < 0])
lstB = [abs(a) for a in lstA]

if cntMinus % 2 == 0:
    ans = sum(lstB)
else:
    ans = sum(lstB) - 2 * min(lstB)
print(ans)

Solution (Python):
import numpy

N = int( input() )
A = list( map( int ,input().split()) )
cnt = sum( lop < 0 for lop in A)

nA = numpy.array(A)
nA = numpy.abs(nA)

lA = nA.tolist()
if min(lA) == 0 or cnt % 2 == 0:
    print(sum(lA))
else :
    print(sum(lA)-min(lA)*2)

Solution (Python):
import numpy as np
n = int(input())
a = [int(i) for i in input().split()]
a = np.array(a, dtype='int64')
k = np.sum(a < 0)
a = np.absolute(a)
a.dtype ='uint64'
a.sort()

if k % 2 == 0:
    print(int(np.sum(a)))
else :
    print(int(np.sum(a)- a[0]*2))

Solution (Python):
n = int(input())
lia = list(map(int,input().split()))
count = 0

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

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

Solution (Python):


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

is_zero = len([a for a in A if a == 0]) > 0
if is_zero:
    print(sum([abs(a) for a in A]))
else:
    minus = len([a for a in A if a < 0])
    abs_list = [abs(a) for a in A]
    if minus % 2 == 0:
        print(sum(abs_list))
    else:
        min_value = min(abs_list)
        print(sum(abs_list) - min_value * 2)

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

cnt = 0
ans = 0
absmin = 10**9
for i in range(N):
    ans += abs(A[i])
    if A[i] < 0:
        cnt += 1
    if abs(A[i]) < absmin:
        absmin = abs(A[i])

if cnt % 2 == 0 or 0 in A:
    print(ans)
else:
    print(ans - 2 * absmin)

Solution (Python):

import sys
INF = float("inf")


def solve(N: int, A: "List[int]"):
    d = [[a > 0, abs(a)] for i, a in enumerate(A)]
    d.sort(key=lambda x: x[1], reverse=True)
    AA = [dv[1] if dv[0] else -dv[1] for dv in d]
    
    s = 0
    for i in range(N-1):
        if AA[i] < 0:
            AA[i] *= -1
            AA[i+1] *= -1
        s += AA[i]
    
    print(s+AA[-1])
    return


def main():

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  
    A = [int(next(tokens)) for _ in range(N)]  
    solve(N, A)


if __name__ == '__main__':
    main()

Solution (Python):
N= int(input())
t = list(map(int, input().split()))
mins= [x for x in t if x<0]

if len(mins)%2 ==0:
    print(sum(map(abs,t)))
else:
    print(sum(map(abs,t))-2*min(map(abs,t)))

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

abs_min = float('inf')
ans = 0
neg_cnt = 0
zero_cnt = 0
for ai in a:
	if abs(ai)<abs_min:
		abs_min = abs(ai)
	if ai<0:
		neg_cnt += 1
	if ai==0:
		zero_cnt += 1
	ans += abs(ai)

if zero_cnt>0:
	print(ans)
elif neg_cnt%2 == 0:
	print(ans)
else:
	print(ans-abs_min*2)

Solution (Python):

from collections import defaultdict
from sys import setrecursionlimit
setrecursionlimit(10**9)
def inpl(): return list(map(int, input().split()))
N = int(input())
A = inpl()

def calc(i):
    if i == N-2:
        return (A[i], A[i+1]), (-A[i], -A[i+1])
    else:
        X, Y = calc(i+1)
        return ([A[i], max(X[0] + X[1], Y[0] + Y[1])],
                [-A[i], max(-X[0] + X[1], -Y[0] + Y[1])])

print(max(map(sum, calc(0))))

Solution (Python):

N = int(input())
A = [int(i) for i in input().split()]
cnt = 0
for a in A:
    if a<0:
        cnt += 1
A = [abs(a) for a in A]
if cnt % 2 == 1:
    print(sum(A)-2*min(A))
else:
    print(sum(A))

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

Solution (Python):
import fractions
from functools import reduce

n = int(input())

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

count= 0
maxi = 10**10
for i in range(n):
    num = a[i]
    if a[i] < 0:
        count +=1
    maxi = min(maxi,abs(num))

if count % 2 == 0:
    print(sum(list(map(lambda x:abs(x),a))))
else:
    print(sum(list(map(lambda x:abs(x),a)))- 2 * maxi)

Solution (Python):
N=int(input())
A=list(map(int,input().split()))
hint=-1
flg=-1
for i in range(N):
  if A[i]==0:
    hint=1
  elif A[i]<0:
    flg= flg*-1
  A[i]=abs(A[i])
A.sort()
ans=0
if hint==1 or hint*flg==1:
  print(sum(A))
else:
  print(sum(A[1:])-A[0])

Solution (Python):
N = int(input())
L = [int(i) for i in input().split()]
import sys

if(0 in L):
    print(sum(list(map(abs,L))))
    sys.exit()

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



if(count%2==0):
    print(sum(list(map(abs,L))))
else:
    print(sum(list(map(abs,L)))-(2*min))

Solution (Python):
def main():
    N = int(input())
    *A, = map(int, input().split())
    minuscount = 0
    A.sort(key=abs)
    for i in A:
        if i < 0:
            minuscount += 1
    maxi = 0
    for i in A:
        maxi += abs(i)
    if minuscount % 2 == 0:
        print(maxi)
    else:
        print(maxi - 2*abs(A[0]))
main()

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

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


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

print(ans)

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

minus = 0
abs_sum = 0
is_zero = False
abs_min = 10**9+1
for i in range(n):
    if a[i] < 0:
        minus += 1
    abs_sum += abs(a[i])
    abs_min = min(abs_min, abs(a[i]))
    if a[i] == 0:
        is_zero = True
if is_zero or minus%2==0:
    print(abs_sum)
elif minus%2 == 1:
    print(abs_sum-abs_min*2)

Solution (Python):
import sys

N=input()
A=map(int, sys.stdin.readline().split())

minus_count=len( filter(lambda x: x<0, A) )

if minus_count%2==0:
	print  sum( map(lambda x: abs(x), A) )
else:
	if 0 in A:
		print  sum( map(lambda x: abs(x), A) )
	else:
		B=map(lambda x: abs(x), A)
		B.sort()
		print sum(B[1:])-B[0]

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

zeroFlag = False
kosuu = 0
absMin = 10000000000
ans = 0
for i in range(n):
    if(a[i]<0):
        kosuu += 1
    elif(a[i]==0):
        zeroFlag = True
    if(abs(a[i])<absMin):
        absMin = abs(a[i])
    ans += abs(a[i])

if(zeroFlag):
    print(ans)
else:
    if(kosuu%2==0):
        print(ans)
    else:
        ans -= 2*absMin
        print(ans)

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

Solution (Python):


import numpy as np
import math
import re

n = int(input())
a = input()
a = re.split(" ",a)
a = list(map(int,a))
count = 0
sum = 0
for i in range(n):
    if(a[i] < 0):
        count += 1
if(count %2 == 0):
    for j in a:
        sum += abs(j)
    print(sum)
else:
    min = 10**9
    t = 0
    for i in range(n):
        if(min > abs(a[i])):
            min = abs(a[i])
            t = i
    for j in range(n):
        if j != t:
            sum += abs(a[j])
        else:
            sum -= abs(a[j])
    
    print(sum)

Solution (Python):
read_ints = lambda : map(int, raw_input().strip().split())

n = input()
a = read_ints()

neg = 0
mn = float('inf')
s = 0
for num in a:
    mn = min(mn, abs(num))
    s += abs(num)
    if num < 0: neg += 1

if neg % 2 == 1:
    print s - 2 * mn
else:
    print s

Solution (Python):
n = int(input())
a = list(map(int, input().split()))
ans = 0
x = 0
y = abs(a[0])

for i in a:
  if i < 0:
    x += 1
    y = min(y, -i)
    ans += -i
  else:
    y = min(y, i)
    ans += i

if x % 2 == 0:
  print(ans)
else:
  print(ans - 2 * y)

Solution (Python):
import math
N = int(input())
A = list(map(int, input().strip().split()))
minus = 0
abs_min = abs(A[0])
sum = 0
for i in range(0, N):
    sum += abs(A[i])
    if A[i] < 0:
        minus += 1
    if abs(A[i]) < abs_min:
        abs_min = abs(A[i])
if minus % 2 != 0:
    sum -= abs_min*2
print("{}".format(sum))

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

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

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


if 0 in a or len([i for i in a if i < 0]) % 2 == 0:
    print(sum(map(abs,a)))
else :
    tmp = sorted(map(abs,a))
    print(sum(tmp[1:])-tmp[0])

Solution (Python):
n = int(input())
a = list(map(int, input().split()))
a_abs = []
n_minus = 0
for ai in a:
    if ai < 0:
        n_minus += 1
        a_abs.append(-1 * ai)
    else:
        a_abs.append(ai)
if n_minus % 2 == 0:
    print(sum(a_abs))
else:
    a_abs.sort()
    print(sum(a_abs[1:]) - a_abs[0])

Solution (Python):
N = int(input())
A = [int(x) for x in input().split()]
mai = 0
for i in range(N):
    if A[i] < 0:
        mai += 1
        A[i] = -A[i]
if mai % 2 == 0:
    print(sum(A))
else:
    A = sorted(A)
    print(sum(A)-2*A[0])

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

n_neg = 0
for A in As:
    if A < 0:
        n_neg += 1

Bs = list(map(abs, As))
if n_neg % 2 == 0:
    ans = sum(Bs)

else:
    Bs = sorted(Bs)
    Bs[0] = -Bs[0]
    ans = sum(Bs)
print(ans)

Solution (Python):
from fractions import gcd
import numpy as np

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

if len(A[A < 0]) % 2 == 0:
    print(np.sum(np.abs(A)))
else:
    minabs_idx = np.argmin(np.abs(A))
    a = np.sum(np.abs(A)) - np.abs(A[minabs_idx])
    b = np.abs(A[minabs_idx])
    print(a - b)

Solution (Python):
import sys
import numpy as np

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

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

A_abs = np.abs(A)
if count % 2 == 0:
    print(np.sum(A_abs))
else:
    print(np.sum(A_abs) - 2 * np.min(A_abs))

Solution (Python):
import numpy as np
N =int(raw_input())
A =map(int ,raw_input().split())
B =np.abs(A)
B = np.array(B,dtype=np.int64)
C = min(B)
D = (sum(B))
E = D - 2*C
k = 0
for i in range(N):
    if A[i]<0:
        k = k+1
if k%2 == 0:
    print D
else:
    print E

Solution (Python):
def is_even(x):
    half = x//2
    if half * 2 == x:
        return 1
    else:
        return 0

def abs(x):
    if x >= 0:
        return x
    else:
        return -x

if __name__ == "__main__":
    N = int(input())
    A = list(map(int,input().split()))
    minus_count = 0
    B = 0
    for a in A:
        if a < 0:
            minus_count += 1
    if is_even(minus_count):
        for a in A:
            B += abs(a)
    else:
        C = [abs(a) for a in A]
        c = min(C)
        B = sum(C) - 2 * c
    print(B)

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

Solution (Python):
n=int(input())
a=list(map(int,input().split()))
ans=0
m=10**10
flg=0
last=0
for i in range(n):
    if a[i]==0:
        flg=1
cnt=len([x for x in a if x<0])

if cnt%2==0 or flg==1:
    for i in range(n):
        ans+=abs(a[i])
else:
    for i in range(n):
        ans+=abs(a[i])
        if m>abs(a[i]):
            m=abs(a[i])
    ans-=2*m
print(ans)

Solution (Python):
from functools import reduce
read = input
n = int(read())
A = list(map(int, read().split()))
if any(map(lambda x:x==0, A)):
    A = map(abs, A)
    print(sum(A))
else:
    cnt = reduce(lambda ac,x:ac + 1 if x < 0 else ac, A, 0)
    if cnt % 2 == 0:
        A = list(map(abs, A))
        print(sum(A))
    else :
        A = list(map(abs, A))
        print(sum(A) - 2*min(A))

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

cnt = 0
for i in range(len(a)):
    if a[i] < 0:
       cnt += 1

b = []
for j in range(len(a)):
    b.append(abs(a[j]))

if cnt % 2 != 0:
        b.append(-2*min(b))

print(sum(b))

Solution (Python):


import itertools
from collections import Counter
from collections import defaultdict
import bisect

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

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

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

    dp[N - 1][0] = dp[N - 2][0] + A[N-1]
    dp[N - 1][1] = dp[N - 2][1] - A[N-1]

    
    print(max(dp[N-1][0], dp[N-1][1]))


if __name__ == '__main__':
    main()

Solution (Python):
a = input()
l = map(int, raw_input().split())
c = 0
ll = []

for i in l:
	if i < 0:
		c += 1
		ll.append(i * -1)
	else:
		ll.append(i)

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

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

'''考え方

特定の配置なら、全部の数字を足せる。
そうでないなら、一番絶対値が小さい値だけ排除、となりそう。

・どこにいようと、0がいたら全ての値を合計できる。


・手順
負の値について、奇数個ブロックが2個あれば消滅できる。
奇数個ブロックが奇数個しかないときは、絶対値が一番小さい値を除外する。
'''


min_abs = 1000000000000
cnt_in_block = 0
cnt_blocks = 0
sum_all = 0


for i,a in enumerate(A):
  
  if a < 0:
    cnt_in_block += 1
  
  
  else:
    
    if i > 0 and A[i-1] < 0:
      if cnt_in_block % 2 != 0:
        cnt_blocks += 1
    
      
      cnt_in_block = 0
    
  tmp = abs(a)
  if min_abs > tmp:
    min_abs = tmp
  sum_all += abs(a)
  
  
  if N -1 == i and cnt_in_block > 0:
    if cnt_in_block % 2 != 0:
      cnt_blocks += 1

  
if cnt_blocks % 2 == 1:
  out = sum_all - 2*min_abs
else:
  out = sum_all
  
print(out)

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

X = len([a for a in A if a < 0])
if X % 2 == 0:
    print(sum([abs(a) for a in A]))
else:
    MIN = float('inf')
    for a in A:
        if abs(a) < MIN:
            MIN = abs(a)
    print(sum([abs(a) for a in A]) - 2 * 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
    A[i] = abs(A[i])

ans = sum(A)
if count%2 == 1:
    ans -= 2*min(A)
print(ans)

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

Solution (Python):
n=int(input())
A=list(map(int,input().split()))
cnt=0
ans=0
for i in range(n):
  if A[i]<0:
    cnt+=1
if cnt%2==0:
  for j in range(n):
    ans+=abs(A[j])
else:
  B=[]
  for k in range(n):
    B.append(abs(A[k]))
  for l in range(n):
    ans+=abs(A[l])
  ans-=2*min(B)
print(ans)

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

n_minus = 0
n_zero = 0
for x in a:
  if x == 0:
    n_zero += 1
  elif x < 0:
    n_minus += 1
r = 0
for x in a:
    r += abs(x)
if n_zero == 0 and n_minus % 2 == 1:
  e = abs(a[0])
  for x in a:
  	e = min(e, abs(x))  
  r -= e * 2
print(r)

Solution (Python):


import sys

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

N=INT()
A=LIST()

mn=INF
cnt=0
zero=False
for i in range(N):
    mn=min(mn, abs(A[i]))
    if A[i]<0:
        cnt+=1
    if A[i]==0:
        zero=True
    A[i]=abs(A[i])

if zero:
    print(sum(A))
elif cnt%2==0:
    print(sum(A))
else:
    print(sum(A)-mn*2)

Solution (Python):
N = int(input())
A = [int(x) for x in input().split()]

total = 0
is_odd = 0
min_number = 1000000001

for i in range(N):
    abs_num = abs(A[i])
    total += abs_num
    if abs_num < min_number:
        min_number = abs_num
    if A[i] < 0:
        is_odd = 1 - is_odd

if is_odd == 1:
    total -= min_number * 2

print(total)

Solution (Python):
N = int(input())
A = [int(c) for c in input().split()]

A_plus, A_minus = [], []
for a in A:
    if a>0: A_plus.append(a)
    else: A_minus.append(a)

if len(A_minus)%2==0:
    print(sum(A_plus) - sum(A_minus))
elif len(A_plus)==0:
    print(sum(A_plus) - sum(A_minus) + max(A_minus)*2)    
else:
    if min(A_plus) > -max(A_minus):
        print(sum(A_plus) - sum(A_minus) + max(A_minus)*2)
    else:
        print(sum(A_plus) - sum(A_minus) - min(A_plus)*2)

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

cnt = 0
b = []
for ai in a:
    if ai <= 0:
        b.append(-ai)
        cnt += 1
    else:
        b.append(ai)
if cnt % 2 == 0:
    ans = sum(b)
else:
    ans = sum(b) - 2 * min(b)
print(ans)

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

neg = 0
for i in a:
    if i<0:
        neg += 1

a = sorted(list(map(abs,a)))
ans = sum(a)
if neg%2 == 1:
    ans -= 2*a[0]
print(ans)