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):
def resolve():
    N = int(input())
    A = list(map(int, input().split()))
    absA = list(map(abs, A))
    negcnt = 0
    for a in A:
        if a < 0:
            negcnt += 1
    if 0 in A or negcnt%2==0:
        print(sum(absA))
    else:
        print(sum(absA)-2*min(absA))



if '__main__' == __name__:
    resolve()

Solution (Python):
n = int(input())
sum_abs_a = 0
min_abs_a = 10 ** 9
minus_odd = False
for a in map(int, input().split()):
  if a < 0:
    minus_odd = not minus_odd
    a = -a
  sum_abs_a += a
  min_abs_a = min(min_abs_a, a)
if minus_odd:
  print(sum_abs_a - 2 * min_abs_a)
else:
  print(sum_abs_a)

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

dp = [[0,0] for i in range(n+1)]
dp[0][1] = (-1)*float('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):
n = int(input())
a = list(map(int, input().split()))
cnt = 0
m = float('inf')
for i in range(n):
    if a[i] < 0:
        a[i] *= -1
        cnt += 1
    m = min(m, abs(a[i]))
if cnt % 2:
    print(sum(a) - 2 * m)
else:
    print(sum(a))

Solution (Python):
n = int(input())
dat = list(map(int, input().split()))
maxval = -9999999999999999999
maxind = -1
numminus = 0
dat2 = []

for i in range(n):
    if dat[i] < 0:
        numminus += 1
    dat2.append(abs(dat[i]))

dat2.sort()



if numminus %2 == 0:
    print(sum(dat2))
else:
    dat2[0] *= -1
    print(sum(dat2))

Solution (Python):
n = int(input())
li = list(map(int,input().split()))
x = 0

for i in range(n):
    if li[i] < 0:
        li[i] *= -1
        x += 1

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

Solution (Python):

"""
Created on Mon Jun  1 13:59:38 2020

@author: NEC-PCuser
"""

N = int(input())
A = list(map(int, input().split()))
minusCount = 0
ans = 0
miniumAbs = 10 ** 9
for i in range(0, len(A)):
    if (A[i] < 0):
        minusCount += 1
    if (miniumAbs > abs(A[i])):
        miniumAbs = abs(A[i])
    ans += abs(A[i])
if minusCount %2 == 0:
    print(ans)
else:
    print(ans - 2 * miniumAbs)

Solution (Python):
n,*a=map(int,open(0).read().split())
b=list(map(abs,a))
print(sum(b)-sum(i<0 for i in a)%2*min(b)*2)

Solution (Python):
n,*a=map(int,open(0).read().split())
b=sum(i<0 for i in a)%2
a=list(map(abs,a))
print(sum(a)-min(a)*2*b)

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

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

count = 0
for x in a:
    if x == 0:
        print(sum(abs_a))
        exit()
    elif x < 0:
        count += 1
if count % 2 == 1:
    mins = min(abs_a)
    print(sum(abs_a) - 2 * mins)
else:
    print(sum(abs_a))

Solution (Python):
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools,fractions,copy
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))

n = inp()
a = inpl()
cnt = 0
for i in range(n):
    if a[i] < 0:
        cnt += 1
a = [abs(x) for x in a]
a.sort()
if cnt%2:
    a[0] = -a[0]
print(sum(a))

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

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

dp[0][0] = 0
dp[0][1] = -float("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):
N = int(input())
A = list(map(int,input().split()))
Sum = 0
Min = float("inf")
cnt = 0
zero = 0

for i in A:
    Min = min(Min,abs(i))
    Sum  += abs(i)
    if i < 0:
        cnt += 1
    elif i == 0:
        zero += 1

if cnt % 2 == 0:
    print(Sum)
elif zero > 0:
    print(Sum)
else:
    print(Sum-2*Min)

Solution (Python):
n = int(input())
a = list(map(int, input().split()))
negative = []
positive = []
cnt=0
for i in range(n):
  if a[i] < 0:
    cnt += 1
    negative.append(a[i])
  else:
    positive.append(a[i])
if cnt % 2 == 0:
  print(sum(map(lambda x: abs(x), a)))
elif cnt == len(a):
  a.sort()
  b = a[-1]
  a.remove(a[-1])
  print(b+sum(map(lambda x: abs(x), a)))
else:
  negative.sort()
  positive.sort()
  if abs(negative[-1]) < positive[0]:
    a.remove(negative[-1])
    print(negative[-1]+sum(map(lambda x: abs(x), a)))
  else:
    a.remove(positive[0])
    print(-positive[0]+sum(map(lambda x: abs(x), a)))

Solution (Python):
N = int(input())
A = list(map(int, input().split()))
abs_min = 10 ** 9
minus = 0
total = 0
for x in A:
    if x < 0:
        minus += 1
        x = - x
    if abs_min > x:
        abs_min = x
    total += x
if minus % 2 == 0:
    print(total)
else:
    print(total - abs_min * 2)

Solution (Python):
n = int(input())
a = list(map(int, input().split()))
c = 0
m = 10**10
flag = 0
ans = 0
for i in a:
    if i == 0:
        flag = 1
    if i < 0:
        c += 1
    ans += abs(i)
    m = min(m,abs(i))
if c%2 == 0:
    flag = 1
if flag:
    print(ans)
else:
    print(ans-(2*m))

Solution (Python):
def main():
    s = open(0).read()
    b = s.count('-')
    z = s.count(' 0 ')
    _, *c, = map(int, s.replace('-', '').split())

    d = min(c)
    e = sum(c)

    if b % 2 == 0 or z > 0:
        print(e)
    else:
        print(e - 2 * d)


if __name__ == '__main__':
    main()

Solution (Python):
def main():
    s = open(0).read()
    b = s.count('-')
    _, *c, = map(int, s.replace('-', '').split())
    z = c.count(0)
    d = min(c)
    e = sum(c)

    if b % 2 == 0 or z > 0:
        print(e)
    else:
        print(e - 2 * d)


if __name__ == '__main__':
    main()

Solution (Python):
def main():
    n, *a = map(int, open(0).read().split())
    b = [i for i in a if i <= 0]
    *ab, = map(abs, a)
    c = sum(ab)
    if len(b) % 2 == 0:
        print(c)
    else:
        print(c - 2 * min(ab))


if __name__ == '__main__':
    main()

Solution (Python):
def main():
    n, *a = map(int, open(0).read().split())
    b = [i for i in a if i <= 0]
    *ab, = map(lambda x: abs(x), a)
    c, d = sum(a), sum(b)
    if len(b) % 2 == 0:
        print(c - 2 * d)
    else:
        print(c - 2 * d - 2 * min(ab))


if __name__ == '__main__':
    main()

Solution (Python):
import numpy as np

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


cnt = np.where(a < 0)[0].shape[0]
a = np.abs(a)

print(a.sum() if cnt % 2 == 0 else a.sum() - a.min() * 2)

Solution (Python):
n=int(input())
a=list(map(int,input().split()))
a.sort()
negative=[]
positive=[]
for ele in a:
    if ele<0:
        negative.append(ele)
    else:
        positive.append(ele)
if len(negative)==0:
    print(sum(a))
else:
    if len(negative)%2==0:
        print(-sum(negative)+sum(positive))
    else:
        if len(positive)==0:
            print(-sum(negative)+2*negative[-1])
        elif -negative[-1]>positive[0]:
            print(-sum(negative)+sum(positive[1:])-positive[0])
        else:
            print(-sum(negative[:-1])+sum(positive)+negative[-1])

Solution (Python):






import sys
input = sys.stdin.readline

import math

import bisect
from collections import defaultdict
from collections import deque
from functools import lru_cache






MOD = 10**9+7
INF = float('inf')






def I(): return int(input().strip())
def S(): return input().strip()
def IL(): return list(map(int,input().split()))
def SL(): return list(map(str,input().split()))
def ILs(n): return list(int(input()) for _ in range(n))
def SLs(n): return list(input().strip() for _ in range(n))
def ILL(n): return [list(map(int, input().split())) for _ in range(n)]
def SLL(n): return [list(map(str, input().split())) for _ in range(n)]


def P(arg): print(arg); return
def Y(): print("Yes"); return
def N(): print("No"); return
def E(): exit()
def PE(arg): print(arg); exit()
def YE(): print("Yes"); exit()
def NE(): print("No"); exit()


def DD(arg): return defaultdict(arg)



def inv(n): return pow(n, MOD-2, MOD)


kaijo_memo = []
def kaijo(n):
  if(len(kaijo_memo) > n):
    return kaijo_memo[n]
  if(len(kaijo_memo) == 0):
    kaijo_memo.append(1)
  while(len(kaijo_memo) <= n):
    kaijo_memo.append(kaijo_memo[-1] * len(kaijo_memo) % MOD)
  return kaijo_memo[n]

gyaku_kaijo_memo = []
def gyaku_kaijo(n):
  if(len(gyaku_kaijo_memo) > n):
    return gyaku_kaijo_memo[n]
  if(len(gyaku_kaijo_memo) == 0):
    gyaku_kaijo_memo.append(1)
  while(len(gyaku_kaijo_memo) <= n):
    gyaku_kaijo_memo.append(gyaku_kaijo_memo[-1] * pow(len(gyaku_kaijo_memo),MOD-2,MOD) % MOD)
  return gyaku_kaijo_memo[n]

def nCr(n,r):
  if(n == r):
    return 1
  if(n < r or r < 0):
    return 0
  ret = 1
  ret = ret * kaijo(n) % MOD
  ret = ret * gyaku_kaijo(r) % MOD
  ret = ret * gyaku_kaijo(n-r) % MOD
  return ret


def factorization(n):
  arr = []
  temp = n
  for i in range(2, int(-(-n**0.5//1))+1):
    if temp%i==0:
      cnt=0
      while temp%i==0: 
        cnt+=1 
        temp //= i
      arr.append([i, cnt])
  if temp!=1:
    arr.append([temp, 1])
  if arr==[]:
    arr.append([n, 1])
  return arr


def make_divisors(n):
  divisors = []
  for i in range(1, int(n**0.5)+1):
    if n % i == 0:
      divisors.append(i)
      if i != n // i: 
        divisors.append(n//i)
  return divisors


def gcd(a, b):
    while b:
        a, b = b, a % b
    return a


def lcm(a, b):
    return a * b // gcd (a, b)


def count_bit(n):
  count = 0
  while n:
    n &= n -1
    count += 1
  return count


def base_10_to_n(X, n):
  if X//n:
    return base_10_to_n(X//n, n)+[X%n]
  return [X%n]

def base_n_to_10(X, n):
  return sum(int(str(X)[-i-1])*n**i for i in range(len(str(X))))


def int_log(n, a):
  count = 0
  while n>=a:
    n //= a
    count += 1
  return count





N = I()
A = IL()

minus = 0
newA = []
for a in A:
  if a<0:
    minus += 1
  newA.append(abs(a))
  
if minus%2 == 0:
  print(sum(newA))
else:
  print(sum(newA)-2*min(newA))

Solution (Python):


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

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

a_plus = [abs(i) for i in a]



if num_minus % 2 == 0:
    print(sum(a_plus))
else:
    print(sum(a_plus)-2*min(a_plus))

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

ans=0;x=10**9;minus_n=0
for a in A:
  if a<0:
    minus_n+=1
    ans+=-a
  else:
    ans+=a
    
  if x>abs(a):
    x=abs(a)

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

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

cnt = 0
f = 0

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




if cnt%2 == 0 or f:
    print(sum(A))
else:
    print(sum(A) - min(A)*2)

Solution (Python):
import numpy as np

n = int(input()) 

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

minus = 0
zero = 0
for num in nums:
    if num == 0:
        zero += 1
        break
    elif num < 0:
        minus += 1

nums = np.abs(nums)
nums.sort()

if minus % 2 and not zero:
    ans = sum(nums) - 2 * nums[0]

else:
    ans = sum(nums)

print(ans)

Solution (Python):
import numpy as np
import collections

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

a=np.array(A, dtype=np.float64)
asign=np.sign(A)
c = collections.Counter(asign)
ar = np.array(c[-1], dtype=np.float64)
ac = a * asign

if c[-1] % 2 == 0:
    print(int(sum(ac)))
else:
    print(int(sum(ac)-min(ac)*2))

Solution (Python):

import numpy as np
from collections import deque
from collections import defaultdict
import heapq
import collections
import itertools
import bisect


mod = 10 ** 9 + 7
N = int(input())
A = np.array(list(map(int, input().split())), dtype=np.int64)
lis = []
ans = 0

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

Solution (Python):
n = int(input())
a = list(map(int,input().split()))
i = 10**9
s = 0
z = 0
c = 0
for b in a:
  if b < 0:
    s += 1
  elif b == 0:
    z += 1
  if abs(b) < i:
    i = abs(b)
  c += abs(b)
if z > 0 or s%2 == 0:
  print(c)
else:
  print(c-2*i)

Solution (Python):
n = int(input())
a = list(map(int, input().split()))
num_sum = 0
num_min = abs(a[0])
num_minus = 0

for i in range(n):
    if (a[i] <= 0):
        num_minus += 1
    num_min = min(num_min, abs(a[i]))
    num_sum += abs(a[i])

if (num_minus % 2 == 0):
    print (num_sum)
else:
    print(num_sum-num_min*2)

Solution (Python):
n = int(input())
a = list(map(int, input().split()))
num_sum = 0
num_min = abs(a[1])
num_minus = 0

for i in range(n):
    if (a[i] <= 0):
        num_minus += 1
    num_min = min(num_min, abs(a[i]))
    num_sum += abs(a[i])

if (num_minus % 2 == 0):
    print (num_sum)
else:
    print(num_sum-num_min*2)

Solution (Python):
import numpy as np
import sys
input = sys.stdin.readline
N = int(input())
A = [int(x) for x in input().split()]
A_count_mynus =[i for i in A if i<0]
A_plus =[abs(i) for i in A]


ans =0
if len(A_count_mynus) %2 ==0:
    ans =sum(A_plus) 
else:
    A_plus.sort()
    ans = -A_plus[0] +sum(A_plus[1:]) 
print(ans)

Solution (Python):
import numpy as np

def main():
    n = int(input())
    a = list(map(int, input().split()))
    A = np.array(a)
    B = np.where(A < 0, A * -1, A)
    cnt = np.count_nonzero(A < 0)
    
    s = B.sum()
    if cnt % 2 == 0:
        print(s)
    else:
        m = np.amin(B)
        print(s - m * 2)
        

if __name__ == "__main__":
    main()

Solution (Python):
n = int(input())
minus = 0
m = float("inf")
s = 0
for i in map(int,input().split()):
    if i < 0:
        minus += 1
        m = min(m,-i)
        s -= i
    else:
        m = min(m,i)
        s += i
if minus % 2 == 0:
    print(s)
else:
    print(s-2*m)

Solution (Python):
n = int(input())
a_list = list(map(int,input().split()))
abs_list = []
minus = 0
check = False
for a in a_list:
  abs_list.append(abs(a))
  if a < 0:
    minus += 1
  if a == 0:
    check = True
if minus % 2 == 0 or check == True:
  print(sum(abs_list))
else:
  print(sum(abs_list) - 2 * min(abs_list))

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

count = 0
for i in range(n):
  if a[i] < 0:
    count += 1
    
if count % 2 == 0:
  print(sum(absa))
else:
  absa.sort()
  temp = absa.pop(0)
  print(sum(absa)-temp)

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

ans=0
m_cnt=0
min_abs=10**18
for i in a:
    if i<0:
        m_cnt+=1
    tmp=abs(i)
    ans+=tmp
    min_abs=min(min_abs, tmp)
if m_cnt%2==0:
    print(ans)
else:
    print(ans-2*min_abs)

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 i in range(N):
    ans += abs(A[i])
  print(ans)
else:
  minabs = 10**9
  for i in range(N):
    minabs = min(minabs, abs(A[i]))
  for i in range(N):
    ans += abs(A[i])
  print(ans - 2*minabs)

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

def read():
    N = int(input().strip())
    A = list(map(int, input().strip().split()))
    return N, A


def solve(N, A):
    abs_a = list(map(abs, A))
    min_a = min(abs_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:
        return sum(abs_a) - min_a * 2
    else:
        return sum(abs_a)


if __name__ == '__main__':
    inputs = read()
    print(solve(*inputs))

Solution (Python):
n = int(input())
a = list(map(int, input().split()))
cnt = 0
m = float('inf')
for i in range(n):
    if a[i] < 0:
        cnt += 1
    if abs(a[i]) < m:
        m = abs(a[i])
ans = 0
for i in range(n):
    ans += abs(a[i])
if cnt % 2 == 1:
    ans -= m * 2
print(ans)

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

hu = []
sei = []
for i in a:
	if i < 0:
		hu.append(i)
	else:
		sei.append(i)
hu.sort()
sei.sort()
if len(hu)%2 == 0:
	ans = sum(sei) + (-1)*sum(hu)
else:
	if len(sei) == 0:
		ans = (-1)*sum(hu[:-1]) + hu[-1]
		print (ans)
		exit()
	else:
		b = sei[0]
	if len(hu) == 0:
		ans = sum(sei[1:] + sei[-1])
		print (ans)
		exit()
	else:
		c = hu[-1]
	if abs(b) <= abs(c):
		b *= -1
		c *= -1
	ans = sum(sei[1:]) + (-1)*sum(hu[:-1])
	ans += (b+c)
print (ans)

Solution (Python):

import sys


def input(): return sys.stdin.readline()[:-1] 



def solve():
    n = int(input())
    a = [int(x) for x in input().split()]
    mn = 1e9
    c = 0
    z = 0
    sm = 0
    for e in a:
        mn = min(mn, abs(e))
        if e < 0:
            c += 1
        if e == 0:
            z += 1
        sm += abs(e)
    if not z:
        if c % 2:
            sm -= 2 * mn

    print(sm)
    
        




t = 1

for case in range(1,t+1):
    ans = solve()



"""
1 -> (1, 2) -> (2 ** 3, 3) -> (3, 1)

"""

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

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

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

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

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

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

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

minus = len([x for x in a if x < 0])
ans = sum(abs(x) for x in a)
if minus % 2 != 0:
    m = min(abs(x) for x in a)
    ans -= m*2

print(ans)

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

Solution (Python):
n = int(input())
a_list = list(map(int,input().split()))
dp = [[0] * 2 for _ in range(n-1)]
dp[0][0] = a_list[0] + a_list[1]
dp[0][1] = -1*(a_list[0] + a_list[1])

for i in range(1,n-1):
    dp[i][0] = max(dp[i-1][0] + a_list[i+1] , dp[i-1][1] + a_list[i+1])
    dp[i][1] = max(dp[i-1][0] - a_list[i+1] -2*a_list[i], dp[i-1][1] - a_list[i+1]+2*a_list[i])
    
print(max(dp[n-2][0] ,dp[n-2][1]))

Solution (Python):
N = int(input())
A = list(map(int,input().split()))
num = 10000000000000000000000000
ans = 0
cnt = 0
for i in range(N):
    a = abs(A[i])
    num = min(num,a)
    ans += a
    if A[i] != a:
        cnt += 1
if cnt%2  == 1:
    ans -= num*2
print(ans)

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

m = 0
b = []
for i in range(n):
    if a[i] < 0:
        m += 1
        b.append(-a[i])
    else:
        b.append(a[i])

if m % 2 == 1:
    print(sum(b) - 2*min(b))
else:
    print(sum((b)))

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

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

min_signs = 0

for num in a:
    if num < 0:
        min_signs += 1

a = list(map(abs, a))

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

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

Solution (Python):



def get_input() -> tuple:
    """
    標準入力の取得

    Returns:\n
        tuple: 標準入力
    """
    N = int(input())
    A = list(map(int, input().split()))

    return N, A


def main(N: int, A: list) -> None:
    """
    求解処理.\n
    数列内の負の数が奇数か偶数かで場合分けを行う.

    Args:\n
        N (int): 整数列内の要素数
        A (list): 整数列
    """
    minus_sign_count = len([a for a in A if a < 0])
    B = [abs(a) for a in A]
    if minus_sign_count % 2 == 1:
        
        B[B.index(min(B))] *= -1
    result = sum(B)

    
    print(result)


if __name__ == "__main__":
    N, A = get_input()
    main(N, A)

Solution (Python):



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



sign_count = len([a for a in A if a < 0])
result = int()
B = [abs(a) for a in A]
if sign_count % 2 == 1:
    B[B.index(min(B))] *= -1
result = sum(B)


print(result)

Solution (Python):
N = int(input())
A = list(map(int, input().split()))
m_cnt = 0
for a in A:
    if a < 0:
        m_cnt += 1

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

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

if m_cnt % 2 == 1:
    ans -= abs(min(A))*2

print(ans)

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

Solution (Python):
n = int(input())
a = list(map(int,input().split()))
dp = [[0]*2 for i in range(n+1)]
dp[0][1] = -float('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 numpy as np
N = int(input())
A = np.array(list(map(int, input().split())))
my_sum = np.sum(np.abs(A))
if np.count_nonzero(A < 0) % 2 == 0:
    print(my_sum)
else:
    print(my_sum - 2 * np.min(np.abs(A)))

Solution (Python):
import itertools
import math
import fractions
import functools
import copy

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

pm = [0,0]

for i in range(n):
    if a[i] == 0:
        print(sum(list(map(abs,a))))
        quit()
    elif a[i] > 0:
        pm[0] += 1
    else:
        pm[1] += 1
if pm[1] % 2 != 0:
    print(sum(list(map(abs,a))) - 2 * min(list(map(abs,a))))
else:
    print(sum(list(map(abs,a))))

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

n_nega = sum(aa<0 for aa in a)
sumabs = sum(abs(aa) for aa in a)
if n_nega%2==0:
    print(sumabs)
else:
    mi=min( abs(aa) for aa in a)
    print(sumabs-mi*2)

Solution (Python):
n = int(input())
a = list(map(int, input().split()))
if 0 in a:
  print(sum(map(abs, a)))
  exit()
minus = len([i for i in range(n) if a[i]<0 ])
if minus % 2 == 0:
  print(sum(map(abs, a)))
else:
  a = sorted(a, key=lambda x: abs(x))
  print(sum(map(abs, a[1:]))-abs(a[0]))

Solution (Python):
import numpy as np
n = int(input())
A = list(map(int,input().split()))
a = np.abs(A)
mainasu = 0

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

if mainasu%2 == 0:
  ans = sum(a)
else:
  a = sorted(a)
  ans = sum(a[1:n]) - a[0]
  
print(ans)

Solution (Python):
import sys

input = sys.stdin.readline

def main():
    N = int(input())
    A = list(map(int, input().split()))
    ans = 0; cnt = 0; tmp = float('inf'); flag = False
    for a in A:
        ans += abs(a)
        tmp = min(tmp, abs(a))
        if a < 0:
            cnt += 1
        elif a == 0:
            flag = True
        else:
            continue
    if cnt%2 == 0:
        flag = True
    if flag:
        print(ans)
    else:
        print(ans - 2*tmp)

if __name__ == "__main__":
    main()

Solution (Python):
from copy import copy, deepcopy












import sys
sys.setrecursionlimit(10 ** 5 + 10)
def input(): return sys.stdin.readline().strip()

def resolve():
    
    N=int(input())
    A=list(map(int,input().split()))
    B=copy(A)
    cnt=0
    for i in range(N):
        if A[i]<0:
            cnt+=1
            B[i]=(-1)*A[i]
    B.sort()
    ans=sum(B)
    if cnt%2==1:
        ans-=B[0]*2
    
    print(ans)

    
resolve()

Solution (Python):
N = int(input())
A = list(map(int, input().split()))
cnt_list = [0, 0, 0]
total = 0
low = 10**9
for a in A:
    low = min(low, abs(a))
    total += abs(a)
    if a == 0:
        cnt_list[1] += 1
    elif a > 0:
        cnt_list[2] += 1
    else:
        cnt_list[0] += 1
if (cnt_list[1] > 0)or(cnt_list[0] % 2 == 0):
    print(total)
else:
    print(total-2*low)

Solution (Python):


import sys






















def main():
    mod = 1000000007                
    inf = float('inf')              
    
    sys.setrecursionlimit(10**6)    
    def input(): return sys.stdin.readline().rstrip()
    def ii():    return int(input())
    def mi():    return map(int, input().split())
    def mi_0():  return map(lambda x: int(x)-1, input().split())
    def lmi():   return list(map(int, input().split()))
    def lmi_0(): return list(map(lambda x: int(x)-1, input().split()))
    def li():    return list(input())
    
    
    n = ii()
    L = lmi()
    minus = len(list(filter(lambda x: x<0, L)))
    pos = list(map(abs, L))
    if minus % 2 == 0:
        print(sum(pos))
    else:
        print(sum(pos) - min(pos) * 2)


if __name__ == "__main__":
    main()

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

Solution (Python):
import numpy as np

N = int(input())
A = np.array(list(map(int, input().split())))
b = np.abs(A)
if np.count_nonzero(A < 0) % 2 == 0:
    print(np.sum(b))
else:
    print(np.sum(b)-np.min(b)*2)

Solution (Python):
N = int(input())
A = list(map(int, input().split()))
ans = 0
minus = 0
mimax = - float('inf')
B = []
for i in range(N):
    if A[i] < 0:
        minus += 1
        B.append(-A[i])
    else:
        B.append(A[i])

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

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

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

B = [abs(i) for i in A]
minus = [int(i<0) for i in A]
if sum(minus)%2 == 0:
    print(sum(B))
else:
    print(sum(B)-2*min(B))

Solution (Python):
def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getList():
    return list(map(int, input().split()))
def getArray(intn):
    return [int(input()) for i in range(intn)]

from collections import defaultdict, deque
from sys import exit
import heapq
import math
import copy
from bisect import bisect_left, bisect_right

import sys


mod = 10 ** 9 + 7

N = getN()
A = getList()
alta = []
cntminus = 0
for i in A:
    if i < 0:
        cntminus += 1
    alta.append(abs(i))
if cntminus % 2 == 0:
    print(sum(alta))
else:
    print(sum(alta) - 2 * min(alta))

Solution (Python):
from operator import itemgetter
import sys
sys.setrecursionlimit(1000000)
ans=0

n=int(input())
a=[]
b=[]
c=0
for i in input().split():
    x=int(i)
    if x<0:
        c+=1
    a.append(x)
    b.append(abs(x))

b.sort()
ans=sum(b[1:])
if c%2==1:
    ans+=-b[0]
else:
    ans+=b[0]
print(ans)

Solution (Python):
def main():
    N = int(input())
    A = [int(_) for _ in input().split()]
    dp = [[0] * 2 for _ in range(N-1)]
    dp[0][0] = A[0] + A[1]
    dp[0][1] = -(A[0] + A[1])
    for i in range(1, N-1):
        dp[i][0] = max(dp[i-1][0]+A[i+1], dp[i-1][1]+A[i+1])
        dp[i][1] = max(dp[i-1][0]-2*A[i]-A[i+1], dp[i-1][1]+2*A[i]-A[i+1])
    print(max(dp[N-2][0], dp[N-2][1]))
    return

if __name__ == '__main__':
    main()

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

m = 10**20
c = 0
for a in A:
    if a < 0:
        c += 1
    m = min(m, abs(a))

if c % 2 == 0:
    ans = sum([abs(a) for a in A])
else:
    ans = sum([abs(a) for a in A]) - m*2

print(ans)

Solution (Python):
DEBUG = False

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

index_min_abs_val = N-1
flag_zero = not A[N-1]
if DEBUG:
    print("index_max_abs_val: {}, flag_zero: {}".format(index_min_abs_val, flag_zero))
for i in range(N-1):
    if not A[i]:
        flag_zero = True
    if abs(A[index_min_abs_val]) > abs(A[i]):
        index_min_abs_val = i
    if A[i] < 0:
        A[i] *= -1
        A[i+1] *= -1
    if DEBUG:
        print("i: {}, A: {}".format(i, A))
        print("index_max_abs_val: {}, flag_zero: {}".format(index_min_abs_val, flag_zero))

if flag_zero:
    A[N-1] = abs(A[N-1])
elif A[N-1] < 0:
    A[N-1] *= -1
    A[index_min_abs_val] *= -1

if DEBUG:
    print("A: {}".format(A))
print(sum(A))

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

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

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

Solution (Python):
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
from itertools import permutations, accumulate, combinations, combinations_with_replacement
from math import sqrt, ceil, floor, factorial
from bisect import bisect_left, bisect_right, insort_left, insort_right
from copy import deepcopy
from operator import itemgetter
from functools import reduce
from fractions import gcd
import sys
def input(): return sys.stdin.readline().rstrip()
def I(): return int(input())
def Is(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def TI(): return tuple(map(int, input().split()))
def IR(n): return [I() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def TIR(n): return [TI() for _ in range(n)]
def S(): return input()
def Ss(): return input().split()
def LS(): return list(input())
def SR(n): return [S() for _ in range(n)]
def SsR(n): return [Ss() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
sys.setrecursionlimit(10**6)
MOD = 10**9+7
INF = float('inf')


n = I()
A = LI()
absmin = INF
minus = 0
for a in A:
    absmin = min(absmin, abs(a))
    if a < 0:
        minus += 1

ans = sum([abs(a) for a in A])
if minus % 2 == 0:
    print(ans)
else:
    print(ans - absmin*2)