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):
from sys import stdin

n = int(stdin.readline().rstrip())
an = list(map(int, input().split()))

m = []
p = []
z = 0

for i in range(n):
  if(an[i]<0):
    m.append(an[i])
  if(an[i]>0):
    p.append(an[i])
  if(an[i]==0):
    z=1

if ( z==1 ):
  ans = sum(p) - sum(m)
elif ( len(m) == 0):
    ans = sum(p)
else:
  if ( len(p) == 0):
    if ( len(m)%2 == 0):
      ans = - sum(m)
    else:
        minm = -max(m)
        ans = -sum(m) - (minm*2)
  else:
    if ( len(m)%2 == 0):
      ans = sum(p) - sum(m)
    else:
      minm = 0
      if ( min(p) < (-max(m)) ):
        minm = min(p)
      else:
        minm = -max(m)
      ans  = sum(p) - sum(m) - (minm*2)

print(ans)

Solution (Python):
N = int(input())
lst_A =list(map(int, input().split()))
neg_count = 0
zero_count = 0
total = 0

if lst_A[0] < 0:
    neg_count += 1
elif lst_A[0] == 0:
    zero_count +=1
total += abs(lst_A[0])
memo = abs(lst_A[0])
i = 1
while i < N:
    if lst_A[i] < 0:
        neg_count += 1
    elif lst_A[i] == 0:
        zero_count +=1
    total += abs(lst_A[i])
    memo = min(memo, abs(lst_A[i]))
    i += 1
if zero_count > 0:
    total = total
elif neg_count % 2 == 1:
    total = total - memo *2
else:
    total = total
print (total)

Solution (Python):
n = int(input())
A = [int(_) for _ in input().split()]
total = sum(A)
neg = 0
pos = 0
neno = []
pono = []
for a in A:
    if a < 0:
        neg += 1
        neno.append(a)
    else:
        pos += 1
        pono.append(a)
neno.sort()
pono.sort()
noneg = -sum(neno) + sum(pono)
if n == 2:
    print(max(-total, total))
else:
    if neg % 2 == 0:
        print(noneg)
    else:
        if pos != 0:
            print(noneg - 2*min(-neno[-1],pono[0]))
        else:
            print(noneg + 2*(neno[-1]))

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

a.sort()
num = 0



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


a = list(map(abs, a))
if num % 2 == 0:
    print(sum(a))
else:
    a.sort()
    print(sum(a) - a[0]*2)

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

s = sum(list(map(lambda x: int(x < 0),A)))
absA = sorted(list(map(lambda a: abs(a), A)))

if s % 2 == 1:
    print(-2*absA[0]+sum(absA))
else:
    print(sum(absA))

Solution (Python):

num = int(input())
data = list(map(int, input().split()))

count_fu = 0
count_zero = 0
for i in range(num):
    if data[i] == 0:
        count_zero += 1
    elif data[i] < 0:
        count_fu += 1

sum_data = 0
min_data = abs(data[0])
for i in range(num):
    sum_data += abs(data[i])
    if abs(data[i]) < min_data:
        min_data = abs(data[i])

if count_fu % 2 == 0:
    print(sum_data)
else:
    print(sum_data - 2 * min_data)

Solution (Python):
n = int(input())
tmp = [i for i in map(int, input().split())]
v_list = []
cnt = 1
for i in tmp:
    if i < 0:
       cnt *= -1
    v_list.append(abs(i))
v_list.sort()
if cnt ==1:
    print(sum(v_list))
else:
    print(sum(v_list[1:]) - v_list[0])

Solution (Python):
import numpy as np

N = int(input())
As=input().split()
A = np.array([int(s) for s in As])
del(As)
Ans = np.sum(np.abs(A))
co = np.sum(A < 0)
if co%2==0:
    print(Ans)
else:
    Ans = Ans - 2*np.amin(np.abs(A))
    print(Ans)

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

m = 10**9
n = 0
abs_sum = 0
for i in range(N):
    a = A[i]
    b = abs(a)
    m = min(m, b)
    abs_sum += b
    if a < 0:
        n += 1

if m == 0:
    print(abs_sum)
elif n%2 == 0:
    print(abs_sum)
else:
    print(abs_sum-2*m)

Solution (Python):
import numpy as np

N = int(input())
A = [int(i) for i in input().split()] 
Acnt = 0
for i in range(N):
	if A[i] < 0:
		Acnt += 1

if Acnt % 2 == 1:
	print(np.sum(np.abs(A)) - np.min(np.abs(A))*2)
elif Acnt % 2 == 0:
	print(np.sum(np.abs(A)))

Solution (Python):
n = int(input())
a = list(map(int,input().split()))
pos = []
neg = []
cnt = 0
for i in a:
    if i > 0:
        pos.append(i)
    elif i < 0:
        neg.append(i)
    else:
        cnt += 1
if cnt != 0 or len(neg) % 2 == 0:
    print(sum(pos) - sum(neg))
else:
    pos = sorted(pos)
    neg = sorted(neg)
    if pos == []:
      print(-sum(neg[:-1])+neg[-1])
      exit()
    else:
      b = min(pos)
    c = -max(neg)
    pos = pos[1:]
    neg = neg[:-1]
    r = sum(pos) - sum(neg)
    m = max(b - c, c - b)
    print(r + m)

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

counter=0

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

li2=li

for i in range(N):
    li2[i]=abs(li[i])

if counter % 2==0:
    mi=0

if counter % 2!=0:
    mi=min(li2)

sumli=0
for i in range(N):
    sumli=abs(li[i])+sumli

sumli=sumli -(mi*2)

print(sumli)

Solution (Python):
import sys
raw_input = sys.stdin.readline
N = int(raw_input())
L = map(int, raw_input().split())
nm = 0
for i in xrange(N):
	if L[i] < 0:
		nm += 1
		L[i] = abs(L[i])

if nm % 2 == 1 :
	print sum(L) - 2 * min(L)
else:
	print sum(L)

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

minabs = 10e9+1
totalsum = 0
flag = 1 
for a in A:
  absa = abs(a)
  
  totalsum += absa
  
  if absa < minabs: minabs = absa
  
  if a == 0:
    flag = 2
  elif a < 0:
    flag *= -1
    

    
print(totalsum if (flag == 1) or (flag == 2) else totalsum - (minabs*2))

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

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

b_list = []

c_list = []
cnt = 0
for a in a_list:
    if a <= 0:
        cnt += 1
    c_list.append(abs(a))

if cnt % 2 != 0:
    print(sum(c_list) - 2 * min(c_list))
else:
    print(sum(c_list))

Solution (Python):
import numpy as np

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

b = np.sort(np.abs(a))
c = np.sum(a < 0)

if c % 2 == 0:
  total = np.sum(b)
else:
  total = np.sum(b[1:]) - b[0]
  
print(total)

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

mc = 0
for e in a:
  if e < 0:
    mc += 1


    
f = 0
if mc % 2 == 1:
  a = [abs(i) for i in a]
  a.sort()
  f = 0
  for i in range(1, n):
    f += a[i]
  f -= a[0]
else:
  for e in a:
    if e >= 0:
      f += e
    else:
      f -= e
      
print(f)

Solution (Python):
N = int(input())
A = [int(i) for i in input().split()]
count_minus = 0
min_abs = 10 ** 9 + 1
sum_abs = 0
for i in range(N):
  if A[i] < 0:
    count_minus += 1
  min_abs = min(min_abs, abs(A[i]))
  sum_abs += abs(A[i])
if count_minus % 2 == 0:
  print(sum_abs)
else:
  print(sum_abs - min_abs * 2)

Solution (Python):
n = int(input())
a = list(map(int,input().split()))
neg = 0
r=0
for i in a:
  r = r + abs(i)
  if i < 0 :
     neg = neg + 1
if neg % 2 != 0:
  s = 10000000000
  for i in a:
    s = min(s,abs(i))
  r = r - 2*s
  
print(r)

Solution (Python):
argN = int(input())
argA = list(map(int,input().split()))

cntP = 0
cntZ = 0
cntM = 0
aryAbsA = []
wkMin = abs(argA[0])

for i in range(argN):
  if argA[i] == 0:
    cntZ += 1
  elif argA[i] > 0:
    cntP += 1
  else:
    cntM += 1
  aryAbsA.append(abs(argA[i]))
  if aryAbsA[i] != 0 and aryAbsA[i] < wkMin:
    wkMin = aryAbsA[i]

if cntZ == 0 and cntM % 2 == 1:
  fix = wkMin
else:
  fix = 0

print(str(sum(aryAbsA) - fix * 2))

Solution (Python):
N=int(input())
A=list(map(int,input().split(' ')))
plus=[A[i] for i in range(N) if A[i]>=0]
minus=[abs(A[i]) for i in range(N) if A[i]<0]

if len(minus)%2 == 0:
	print(sum(plus)+sum(minus))
else:
	newl = sorted(plus + minus)[::-1]
	print(sum(newl[:-1]) - newl[-1])

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):
import numpy as np
n=int(input())
a=np.array([int(i) for i in input().split()])

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

Solution (Python):
import numpy as np
n=int(input())
a=np.array(list(map(int,input().split())),dtype='int64')
if np.sum(a<0)%2==0:
    a=abs(a)
else:
    a=abs(a)
    a[a.argmin()]=-a[a.argmin()]

print(int(sum(a)))

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

neg_count = 0
max_neg = -10**9-1
max_neg_i = -1
min_pos = 10**9+1
min_pos_i = -1
total2 = 0
for i in range(N):
    if As[i] >= 0 and As[i] < min_pos:
        min_pos = As[i]
        min_pos_i = i
    if As[i] < 0 and As[i] > max_neg:
        max_neg = As[i]
        max_neg_i = i
    total2 += abs(As[i])
    if As[i] < 0:
        neg_count += 1

if neg_count % 2 == 0:
    print(total2)
else:
    cands = []
    if min_pos_i >= 0:
        cands.append(total2 - min_pos*2)
    if max_neg_i >= 0:
        cands.append(total2 + max_neg*2)
    print(max(cands))

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

absA = [abs(A[i]) for i in range(N)]
minA = min(absA)
sumA = sum(absA)
minus = 0
for i, a in enumerate(A):
    if a < 0:
        minus += 1

if minus % 2 == 0:
    ans = sumA
else:
    ans = sumA - 2 * minA

print(ans)

Solution (Python):
n = int(input())
a = list(map(int,input().split()))
x = 0
for i in range(n):
    if a[i]<0:
        x += 1
for i in range(n):
    a[i]=abs(a[i])


if x%2 == 0:
    print(sum(a))
else:
    m = min(a)
    print(sum(a)-2*m)

Solution (Python):
n=int(input())
l=[int(i) for i in input().split()]
num=0
for i in l:
    if i<0:
        num+=1
res=0
for i in l:
    if i>0:
        res+=i
    else:
        res+=-1*i
p=10**10
for i in l:
    p=min(abs(i),p)
if num%2==0:
    A=True
else:
    A=False

if A:
    print(res)
else:
    print(res-2*p)

Solution (Python):



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

count_minus = 0
for x in X:
    if x < 0:
        count_minus += 1
        
if count_minus % 2 == 0:
    print(sum(map(abs, X)))
else:
    print(sum(map(abs, X)) - 2 * min(map(abs, X)))

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

if sum(a < 0 for a in A) & 1:
	print(sum(map(abs, A)) - 2 * min(abs(a) for a in A))
else:
	print(sum(map(abs, A)))

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

for i in range(0,N-1,2):
    if A[i+1] > 0 and abs(A[i]) < abs(A[i+1]):
        break
    if A[i] > 0 and A[i+1] > 0:
        break
    A[i] *= -1
    A[i+1] *= -1
print(sum(A))

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

Solution (Python):
n = int(input())
num_list = list(map(int,input().split()))
i = 0
neg_count = 0
while(i < n):
    if num_list[i] < 0:
        neg_count += 1
        num_list[i] *= -1
    i += 1
num_list = sorted(num_list)
if neg_count %2 == 0:
    print(sum(num_list))
else:
    num_list[0] *= -1
    print(sum(num_list))

Solution (Python):
n = int(input())
inputlist = list(map(int, input().split()))
count = 0
isZero = 0
minabs = float("inf")
abslist = []

for i in range(n):
  ith = inputlist[i]
  if ith == 0:
    isZero = 1
  if ith < 0:
    count += 1
  if abs(ith) < minabs:
    minabs = abs(ith)
  abslist.append(abs(ith))
  
ans = 0
if count % 2 == 0 or isZero == 1:
  for j in range(n):
    ans += abslist[j]
  print(ans)
else:
  for k in range(n):
    ans += abslist[k]
  ans -= 2 * minabs
  print(ans)

Solution (Python):
N = int(input())
al = [int(a) for a in input().split()]

ans = 0

c_minus = 0
abs_min = 1e10

for i in range(N):
    a = al[i]
    if a < 0:
        c_minus += 1
    if abs(a) < abs_min:
        abs_min = abs(a)
    ans += abs(a)
    
if c_minus % 2 == 0:
    print(ans)
else:
    print(ans - 2 * abs_min)

Solution (Python):
n=int(input())
l=list(map(int,input().split()))
minuscount=0
zerocount=0
for i in range(len(l)):
  if l[i]<0:
    minuscount+=1
  elif l[i]==0:
    zerocount+=1
absl=[abs(l[i]) for i in range(len(l))]
if minuscount%2==0:
  print(sum(absl))
else:
  if zerocount>0:
    print(sum(absl))
  else:
    absl.sort(reverse=True)
    print(int(sum(absl)-2*absl[-1]))

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

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

minusCnt = 0
absMin = 10**10


for i in range(len(A)):
	if abs(A[i]) < absMin:
		absMin = min( abs(A[i]), absMin )
		absMinIndex = i
	if A[i] < 0:
		minusCnt+=1

if minusCnt % 2 == 0:
	
	for i in range(len(A)):
		if A[i] < 0:
			A[i] *= -1
else:
	
	for i in range(len(A)):
		if absMinIndex == i:
			if 0 < A[i]:
				A[i] *= -1
		if A[i] < 0 and i != absMinIndex:
			
			A[i] *= -1

ans = sum(A)

print(ans)

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

S=0
for a in A:
    S+=abs(a)




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

Solution (Python):
n = int(input())
m = 10**9
cn = 0
s = 0
for x in input().split():
    y = int(x)
    z = abs(y)
    if y < 0:
        cn += 1
    s += z
    if m > z:
        m = z
if cn%2 == 0:
    print(s)
else:
    print(s - m*2)

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

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

for i in range(n):
    a[i] = abs(a[i])

ans = 0
for i in range(n):
    ans += a[i]
if m%2 == 0:
    print(ans)
else:
    print(ans-2*min(a))

Solution (Python):
N=int(input())
a=list(map(int,input().split()))
b=[abs(a[i]) for i in range(N)]
d=[0]*N
M=sum(b)

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

if d[N-1]%2==0 or 0 in a:
    print(M)

else: print(M-min(b)*2)

Solution (Python):
N = int(input())
A = list(map(int, input().split()))
c = 0
min_abs = float('inf')
for i in range(N):
  if A[i] < 0:
    c += 1
  if abs(A[i]) < min_abs:
    min_abs = abs(A[i])

s = 0

if c % 2 == 0:
  for i in range(N):
    s += abs(A[i])
else:
  for i in range(N):
      s += abs(A[i])
  s -= abs(min_abs) * 2

print(s)

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 += 1

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

Solution (Python):
num = int(input())
values = list(map(int, input().split()))
count = 0
for index, value in enumerate(values):
    if value < 0:
        count += 1
    values[index] = abs(value)

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

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

Solution (Python):
N = int(input())
A = list(map(int, input().split()))
mn = len(list(filter(lambda x: x < 0, A)))
ans = [-A[i] if A[i] < 0 else A[i] for i in range(N)]
if mn % 2 == 0:
    print(sum(ans))
else:
    print(sum(ans)-min(ans)*2)

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

neg = [ai for ai in an if ai < 0]

sum = 0
mini = 10 ** 9
for ai in an:
  sum += abs(ai)
  mini = min(mini, abs(ai))
  
if len(neg) % 2 != 0:
  sum -= 2 * mini

print(sum)

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


cnt=0
ans=0
mina=float('inf')

for i in range(n):
  if a[i] >= 0:
    ans+=a[i]
    mina=min(mina,a[i])
  else:
    ans-=a[i]
    cnt+=1
    mina=min(mina,-a[i])
    
if a.count(0)>0:
  print(ans)
elif cnt%2==0:
  print(ans)
else:
  print(ans-2*mina)

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 = sorted(list(map(int,input().split())),key=lambda x:abs(x))

a = 0
for i in A:
  if i < 0:
    a += 1
  elif i == 0:
    a = -1
    break

ans = 0
if a == -1 or a % 2 == 0:
  ans = sum([abs(x) for x in A])
else:
  ans = abs(A[0]) * -1
  for a in A[1:]:
    ans += abs(a)
print(ans)

Solution (Python):


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

def answer(l):
    abs_l = []
    cnt_neg = 0

    for v in l:
        abs_l.append(abs(v))
        if v < 0:
            cnt_neg += 1  

    if test:
        print('abs_l  :', abs_l)
        print('cnt_neg:', cnt_neg)

    
    if cnt_neg % 2 == 0:
        return sum(abs_l)

    
    return sum(abs_l) - 2 * min(abs_l)


def main():
    print(answer(A))


if __name__ == '__main__':
    main()

Solution (Python):

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

A.sort()
posA = 0
negcnt = 0
absmin = 10**9
for itm in A:
    if itm < 0:
        negcnt += 1
    absmin = min(absmin, abs(itm))
    posA += abs(itm)
ifNodd = N % 2
ifnegodd = negcnt % 2





if ifnegodd == 1:
    ans = posA - 2*absmin
else:
    ans = posA
print(ans)

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

cnt=0
for i in A:
    if i < 0:
        cnt += 1

X=[]
for i in A:
    X.append(abs(i))

if cnt % 2 == 0:
    print(sum(X))
else:
    print(sum(X) - (min(X)*2))

Solution (Python):
import numpy as np
N = int(input())
A = np.array([int(i) for i in input().split()])

minus = len(A[np.where(A < 0)])
abs_list = [abs(0-i) for i in A]
res = sum(abs_list)
if minus % 2 != 0:
    m = min(abs_list)
    res -= m * 2
print(res)

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

A_k = [i for i in A if i < 0]

A_abs = list(map(abs, A))

if len(A_k) % 2 == 0:
    print(int(sum(A_abs)))
    exit()
else:
    print(int(sum(A_abs) - 2 * min(A_abs)))

Solution (Python):
min_val = 10 ** 9
N = int(input())
A = list(map(int, input().split()))
minus_conut = 0
sum_val = 0
for num in A:
    if num < 0:
        minus_conut += 1
    abs_val = abs(num)
    min_val = min(min_val, abs_val)
    sum_val += abs_val

if minus_conut % 2 == 0:
    print(sum_val)
else:
    print(sum_val - 2 * min_val)

Solution (Python):


N = int(input())
A_lst = input().split()

abs_min = 10**9
count_minus = 0
abs_A_lst = []

for i in range(N):
    A_lst[i] = int(A_lst[i])
    abs_A_lst.append(abs(A_lst[i]))
    if abs_A_lst[-1] < abs_min:
        abs_min = abs_A_lst[-1]
    if A_lst[i] < 0:
        count_minus += 1

output = sum(abs_A_lst)
if count_minus % 2 == 1:
    output -= abs_min*2

print(output)

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

Solution (Python):
N = int(input())
A = list(map(int, input().split()))
count = 0
sumabs = 0
minabs = 10 ** 10
for i in range(N):
    if A[i] < 0:
        count += 1
    sumabs += abs(A[i])
    minabs = min(minabs, abs(A[i]))

if count % 2 == 0:
    print(sumabs)
else:
    print(sumabs-2*minabs)

Solution (Python):
N = int(input())
A = sorted([int(_) for _ in input().split()])
ans = sum(A)
for i in range(1, N // 2 + 1):
    a1 = ans - 2 * (A[2 * i - 2] + A[2 * i - 1])
    if a1 < ans:
        break
    ans = a1
print(ans)

Solution (Python):
n = int(input())
a = list(map(int, input().split()))
cntm = cntz = 0
for i in range(n):
    if a[i] < 0:
        cntm += 1
    elif a[i] == 0:
        cntz += 1
ans = 0
for i in range(n):
    ans += abs(a[i])
if cntm%2 == 0 or cntz > 0:
    print(ans)
else:
    abmin = 10**15
    for i in range(n):
        if abs(a[i]) < abmin:
            abmin = abs(a[i])
    print(ans - 2*abmin)

Solution (Python):
N = int(input())
A = list(map(int, input().split()))
check = list(map(lambda x:1 if x>-1 else 0, A)).count(0)%2
A = list(map(abs,A))
if check:
    print(sum(A)-min(A)*2)
else:
    print(sum(A))

Solution (Python):



def solve(xs):
    num_neg = sum(x < 0 for x in xs)
    ys = sorted(abs(x) for x in xs)
    if num_neg % 2 == 0:
        res = sum(ys)
    else:
        res = -ys[0] + sum(ys[1:])
    return res


def main():
    _ = int(input())
    xs = [int(z) for z in input().split()]
    print(solve(xs))


if __name__ == "__main__":
    main()

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

zero_count = 0
minus_count = 0
s = 0
min_num = abs(a[0])

for i in range(n):
    if a[i] < 0:
        minus_count += 1
    elif a[i] == 0:
        zero_count += 1
    s += abs(a[i])
    min_num = min(min_num, abs(a[i]))

if minus_count % 2 == 0:
    print(s)
else:
    if zero_count == 0:
        print(s - 2 * min_num)
    else:
        print(s)

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

abs_a = []
minuses = 0

for _a in a:
	if _a < 0:
		minuses += 1
	abs_a.append(abs(_a))

if minuses % 2 == 0:
	print(sum(abs_a))
else:
	print(sum(abs_a) - 2 * min(abs_a))

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

Solution (Python):
N = int(input())
A_list = list(map(int, input().split()))
n_minus = 0
for a in A_list:
    if a < 0:
        n_minus += 1
if int(n_minus)%2 == 0:
    print(sum([abs(a) for a in A_list]))
else:
    tmp = sorted([abs(a) for a in A_list])
    print(int(sum(tmp[1:]) - tmp[0]))

Solution (Python):
import sys

sys.setrecursionlimit(10000)
INF = float('inf')

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

odd = False
for i in range(len(A)):
    if A[i] < 0:
        A[i] *= -1
        odd = not odd

if odd:
    print(sum(A) - min(A) * 2)
else:
    print(sum(A))

Solution (Python):
import sys

sys.setrecursionlimit(10000)
INF = float('inf')

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

odd = False
for i in range(len(A)):
    if A[i] < 0:
        A[i] *= -1
        odd = not odd

if odd:
    print(sum(A) - min(A) * 2)
else:
    print(sum(A))

Solution (Python):
n=int(input())
l=list(map(int,input().split()))
l2=[]
hugoc=0
for i in range(n):
  x=l[i]
  if x<0:
    hugoc+=1
  l2.append(abs(x))
l2.sort()
if hugoc%2==0:
  print(sum(l2))
else:
  print(sum(l2[1:])-l2[0])

Solution (Python):

N=int(input())
A=list(map(int,input().split()))
B=A[::]
for i in range(N-1):
    if A[i] > 0:
        pass
    else:
        A[i]=(-1*A[i])
        A[i+1]=(-1*A[i+1])
if min(A) >= 0:
    print(sum(A))
else:
    C=B[::]
    for i in range(N):
        C[i]=max(-1*C[i],C[i])
    print(sum(C)-2*min(C))

Solution (Python):
N = int(input())
A = list(map(int,input().split()))
gu=False
min_i = [0,10**5]
count = 0
for i in range(N):
    if(A[i] < 0):
        count = count + 1

if(count%2 == 0):
    gu=True

if(gu or 0 in A):
    print(sum(list(map(abs,A))))
else:

    for i in range(N):
        if(abs(A[i])<min_i[1]):
            min_i[0] = i
            min_i[1] = abs(A[i])
    a =sum(list(map(abs,A)))
    print(a-min_i[1]*2)

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

minabs = 10 ** 9
numneg = 0

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

    minabs = min(minabs, A[i])

print(sum(A) if numneg % 2 == 0 else sum(A) - 2 * minabs)

Solution (Python):
N = int(input())
A = list(map(int, input().split()))
A_min = 10000000000
negative_count = 0
ans = 0

for i in range(N):
    if abs(A[i]) < A_min:
        A_min = abs(A[i])
    if A[i] < 0:
        negative_count += 1
    ans += abs(A[i])

if negative_count % 2 == 0:
    print(ans)
else:
    ans -= A_min*2
    print(ans)

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

count = 0
p = 10**9
sum_l = 0
for i in l:
    sum_l += abs(i)
    p = min(p,abs(i))
    if i < 0:
        count += 1

if count%2 == 0:
    print(sum_l)
else:
    print(sum_l-2*p)

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

Solution (Python):
N = int(input())
A = list(map(int, input().split()))
n_minus = 0
has_zero = False
for i, a in enumerate(A):
    if a < 0:
        n_minus += 1
    if a == 0:
        has_zero = True
    A[i] = abs(a)

if has_zero:
    print(sum(A))
else:
    if n_minus % 2 == 0:
        print(sum(A))
    else:
        print(sum(A) - 2*min(A))

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

Solution (Python):
N = int(input())
A = [int(x) for x in input().split()]
ABS = sorted([abs(a) for a in A])
minus = sum([1 for a in A if a < 0])
if minus % 2:
  ABS[0] *= -1
print(sum(ABS))

Solution (Python):
import numpy as np

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

A_allplus = np.where(A>=0,A,-A)

plus = A[A>=0]
minus = A[A<0]

d = 0
if len(minus)%2==1:
    a = np.inf
    b = np.inf
    if len(minus)>0:
        a = max(minus)
    if len(plus)>0:
        b = min(plus)
    
    
    d = min(abs(a),abs(b))*2

print(sum(A_allplus)-d)

Solution (Python):
N=int(input())
A=[int(i) for i in input().split()]
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:
	print(sum(A))
else:
	A[N-1]=-A[N-1]
	aa=min(A)
	print(sum(A)-aa-aa)

Solution (Python):
N = int(input())
A = list(map(int,input().split()))
minnumber = -1
answer = 0
number = 0

for x in range(len(A)):
    if A[x] < 0:
        A[x] = abs(A[x])
        number += 1
    answer += A[x]
    if minnumber == -1 or minnumber > A[x]:
        minnumber = A[x]

if number % 2 == 0:
    print(answer)
else:
    answer -= minnumber * 2
    print(answer)

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]=-A[i]
print(sum(A) if count%2==0 else sum(A)-min(A)*2)

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

fugo = [a < 0 for a in A]
seiA = [abs(a) for a in A]

ans = sum(seiA)
if sum(fugo) % 2 == 0:
    print(ans)
else:
    print(ans - 2 * min(seiA))

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

Solution (Python):
def main():
    N = int(input())
    a = list(map(int, input().split()))
    b = [abs(x) for x in a]
    n = sum(map(lambda x: x < 0, a))

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


if __name__ == '__main__':
    main()

Solution (Python):
n = int(input())
a = [int(i) for i in input().split(" ")]
c = 0
z = False
for i in range(0, n):
    if a[i] == 0:
        z = True
    elif a[i] < 0:
        c += 1

if z or c % 2 == 0:
    print(sum([abs(i) for i in a]))
else:
    ab = [abs(i) for i in a]
    print(sum(ab) - 2 * min(ab))

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

ans = 0
plus = 0
minus = 0
zero = 0
min = 10**9

for i in range(N):
    if A[i] == 0:
        zero += 1
    elif A[i] > 0:
        plus += 1
    else:
        minus += 1
    ans += abs(A[i])
    if min > abs(A[i]):
        min = abs(A[i])

if zero > 0 or minus%2==0:
    print(ans)
else:
    print(ans - min*2)

Solution (Python):
N = int(input())
A = [int(x) for x in input().split()]
count = 0
ab_sum = 0
min = 1000000000

for i in range(N):
    ab = 0

    if A[i] >= 0:
        ab_sum += A[i]
        ab = A[i]
    else:
        count += 1
        ab_sum -= A[i]
        ab = -A[i]
    if ab < min:
        min = ab

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

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

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

if A[-1] < 0:
    A[-1] *= -1
    print(sum(A) - 2*min(A))
else:
    print(sum(A))

Solution (Python):
N=int(input())
A=map(int,input().split())
a_min=10**9
ans=0
neg=0
for a in A:
    aa=abs(a)
    ans+=aa
    if a<0:
        neg+=1
    if a_min>aa:
        a_min=aa
if neg%2==1:
    ans-=a_min*2
print(ans)

Solution (Python):


N = int(input())
A = list(map(int, input().split()))
A2 = [-a if a<0 else a for a in A]
N2 = len([a for a in A if a<0])

if N2 % 2 == 0:
    print(sum(A2))
else:
    print(sum(A2) - min(A2) * 2)

Solution (Python):
import math
import functools
import itertools
import numpy as np
import sys
MAX_INT = int(10e10)
MIN_INT = -MAX_INT
mod = 1000000007
sys.setrecursionlimit(1000000)
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()


N = I()
A = IL()

SUM = 0
cnt = 0
MIN = MAX_INT
for i in range(N):
  if A[i] < 0:
    tmp = -A[i]
    cnt += 1
  else:
    tmp = A[i]
  MIN = min(MIN,tmp)
  SUM += tmp

if cnt%2 == 0:
  print(SUM)
else:
  print(SUM-MIN*2)

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


A=list(map(int,input().split()))
m=10**19
count=0
for i in A:
    if abs(i)<m:
        m=abs(i)
    if i<0:
        count+=1
if count%2==0:
    print(sum([abs(i) for i in A]))
else:
    print(sum([abs(i) for i in A])-2*m)

Solution (Python):
n = int(input())
a = [int(m) for m in input().split()]
S = 0
for i in range(n):
    S += abs(a[i])
fu = 0
minabs = float("INF")
for i in range(n):
    if a[i] < 0:
        fu += 1
    minabs = min(minabs, abs(a[i]))

if n % 2 == 0:
    if fu % 2 == 0:
        print(S)
    else:
        print(S - 2 * minabs)
else:
    if fu % 2 == 0:
        print(S)
    else:
        print(S - 2 * minabs)