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 importlib
def import_module(name):return importlib.import_module(name)

input = import_module('sys').stdin.readline
def input_int():return int(input())
def input_ints():return map(int,input().split())
def input_ints_list():return list(input_ints())
def input_str():return input()
def input_strs():return input().split()
def input_lines(n,f):return [f() for _ in range(n)]

def gcd_base(a,b):return import_module('fractions').gcd(a,b) 
def gcd(a):return import_module('functools').reduce(gcd_base,a) 
def lcm_base(a,b):return (a*b)//gcd_base(a,b) 
def lcm(a):return import_module('functools').reduce(lcm_base,a,1) 

def permutations(a,n):return import_module('itertools').permutations(a,n) 
def combinations(a,n):return import_module('itertools').combinations(a,n) 
def product(a,b):return import_module('itertools').product(a,b) 

def init_array_1dim(v,n):return [v]*n
def init_array_2dim(v,n,m):return [init_array_1dim for _ in range(m)]


def ceil(a):return import_module('math').ceil(a) 
def floor(a):return import_module('math').floor(a) 


def init_q(a):return import_module('collections').deque(a)
def q_pop(a):return a.popleft()
def q_push(a,v):a.appendleft(v)
def q_pushlist(a,l):a.extendleft(l)
def q_append(a,v):a.append(v)
def q_appendlist(a,l):a.extend(l)


def init_heap(a):import_module('heapq').heapify(a)
def heap_push(a,v):import_module('heapq').heappush(a,v)
def heap_pop(a):return import_module('heapq').heappop(a) 


def bisect_left(a,x):return import_module('bisect').bisect_left(a,x)
def bisect_right(a,x):return import_module('bisect').bisect_left(a,x)
def insert_left(a,x):return import_module('bisect').insert_left(a,bisect_left(a,x))
def insert_right(a,x):return import_module('bisect').insert_right(a,bisect_right(a,x))


def cumsum(a):return import_module('numpy').cumsum(import_module('numpy').array(a)) 
def cumprod(a):return import_module('numpy').cumprod(import_module('numpy').array(a)) 
def cumgcd(a):return import_module('numpy').frompyfunc(gcd_base, 2, 1).accumulate(a, dtype=import_module('numpy').object).astype(import_module('numpy').int) 

class UnionFind(object):
    def __init__(self, n):
        self.par = [i for i in range(n)]
        self.rank = [0 for _ in range(n)]
        self.size = [1 for _ in range(n)]

    def find(self, x):
        if self.par[x] == x:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x != y:
            if self.rank[x] < self.rank[y]:
                x, y = y, x
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1
            self.par[y] = x
            self.size[x] += self.size[y]

    def is_same(self, x, y):
        return self.find(x) == self.find(y)

    def get_size(self, x):
        x = self.find(x)
        return self.size[x]

def dfs(pos):
    ret = 0
    l = []
    for e in l:
        next = e
        ret += dfs(next)
    return ret

def bfs(l):
    q = init_q(l)
    pos = 0
    q_push(q,pos)
    while q:
        now = q_pop(q)
        for e in l:
            next = e
            q_append(q,next)


def warshall_floyd(n,graph):
    d = init_array_2dim(float("inf"),n,n)
    
    for i in range(n):
        d[i][i] = 0
        for j in range(n):
            if graph[i][j]:d[i][j] = 1
    
    for k in range(n):
        for i in range(n):
            for j in range(n):
                d[i][j] = min(d[i][j],d[i][k] + d[k][j])
    return d


def init_graph(n,a,directed=False):
    visited = init_array_1dim(False,n)
    graph = init_array_2dim(False,n,n)
    for e in a:
        graph[e[0]-1][e[1]-1] = True
        if not directed:graph[e[1]-1][e[0]-1] = True 
    return visited,graph

def two_pointers(s,threshold,ope='sum'):
    l,r = 0,0
    base = 0 
    if ope == 'sum':base = 0
    if ope == 'prd':base = 1
    diff = 0
    while r < len(s):
        val = 0
        if ope == 'sum':val = base+s[r]
        if ope == 'prd':val = base*s[r]
        if val <= threshold:
            if ope == 'sum':base += s[r]
            if ope == 'prd':base *= s[r]
            diff = max(diff, r-l+1)
            r += 1
        elif l == r:
            r += 1
            l += 1
        else:
            if ope == 'sum':base -= s[l]
            if ope == 'prd':base //= s[l]
            l += 1
    return diff


def solution():
    import numpy as np

    global N,A
    N = input_int()
    A = input_ints_list()

    A = np.array(A)
    cnt = len(np.where(A < 0)[0])
    A = np.abs(A)
    A.sort()

    if cnt%2 == 1:A[0] *= -1
    print(A.sum())
    
	
if __name__ == '__main__':
    solution()

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

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

neg_cnt = 0
abs_min = 999999999999999
for an in alist:
  if an < 0:
    neg_cnt += 1
  if abs_min > abs(an):
    abs_min = abs(an)
 
ans = 0
for i in range(N):
  ans += abs(alist[i])
  
if neg_cnt%2 == 0:
  print(ans)
else:
  print(ans-2*abs_min)

Solution (Python):
N=int(input())
al=input().split()
mc = 0
tt = 0
min = abs(int(al[0]))

for i in range(N):
    if int(al[i]) < 0:
        mc += 1
    tt += abs(int(al[i]))

    if min > abs(int(al[i])):
       min = abs(int(al[i]))

if (mc % 2):
    print(tt-2*min)
else:
    print(tt)

Solution (Python):
N=int(input())
al=input().split()
mc = 0
tt = 0
min = abs(int(al[0]))

for i in range(N):
    if int(al[i]) < 0:
        mc += 1
    tt += abs(int(al[i]))

    if min > abs(int(al[i])):
       min = abs(int(al[i]))

if (mc % 2):
    print(tt-2*min)
else:
    print(tt)

Solution (Python):
input()
a_tuple = tuple(map(int, input().split()))
abs_a_tuple = tuple(map(abs, a_tuple))
minus_cnt = len([x for x in a_tuple if x < 0])
print(sum(abs_a_tuple) - 2 * (minus_cnt & 1) * min(abs_a_tuple))

Solution (Python):
import sys

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

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

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

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

negative_num = len([a for a in a_list if a < 0])
zero_num = len([a for a in a_list if a == 0])
abs_a_list = list(map(abs, a_list))

if negative_num % 2 == 0 or zero_num >= 1:
    print(sum(abs_a_list))
else:
    print(sum(abs_a_list) - 2 * min(abs_a_list))

Solution (Python):

n = int(input())
nums = list(map(int,input().split()))
cnt = 0
for num in nums:
  if num < 0:
    cnt += 1
    
abnums = [abs(i) for i in nums]
if cnt % 2 == 0:
  ans = sum(abnums)
else:
  ans = sum(abnums) - min(abnums)*2
print(ans)

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

negCount = 0


sum = 0


min = 0
if A[0] < 0:
    min = A[0] * -1
else:
    min = A[0]

for i in A:
    
    if i < 0:
        negCount += 1
        i *= -1

    sum += i

    if i < min:
        min = i

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

Solution (Python):
def getNumNeg(L):
  return sum([i<0 for i in L])
  
def findmax2(L):
  numNeg = getNumNeg(L)
  absL = list(map(abs, L))
  if numNeg % 2 == 0:
    print(sum(absL))
  else:
    print(sum(absL)-2*min(absL))
        
n = int(input())
a = list(map(int, input().split()))
findmax2(a)

Solution (Python):
n = int(input())
A = [int(i) for i in input().split()]
A.insert(0, 0)
dp = list([0] * 2 for i in range(n+1))
dp[0][0] = 0
dp[0][1] = -1000000000000
for i in range(1, n) :
    dp[i][0] = max(dp[i-1][0] + A[i], dp[i-1][1] - A[i])
    dp[i][1] = max(dp[i-1][0] - A[i], dp[i-1][1] + A[i])
ans = max(dp[n-1][0] + A[n], dp[n-1][1] - A[n])    

print(ans)

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

negs = 0
for x in num:
    if x < 0:
        negs += 1

num = list(map(lambda x: abs(x), num))

if negs % 2 == 0:
    ans = sum(num)
else:
    ans = sum(num)
    ans -= 2 * min(num) 

print(ans)

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

Abs_A = list(map(abs, A))
sum_Abs = sum(Abs_A)
count = 0

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

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

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

Abs_A = list(map(abs, A))
sum_Abs = sum(Abs_A)
count = 0

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

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

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

cnt_min = len([i for i in list if i < 0])
num_min = min([abs(i) for i in list])
sum_abs = sum([abs(i) for i in list])

if cnt_min%2 == 0:
    print(sum_abs)
else:
    print(sum_abs-2*num_min)

Solution (Python):
import sys
input = sys.stdin.readline
N = int(input())
A = list(map(int, input().split()))

minus_num = 0
minimum_abs = int(1e20)
total_sum = 0
for v in A:
    minimum_abs = min(abs(v), minimum_abs)
    total_sum += abs(v)
    if v < 0:
        minus_num += 1
if minus_num % 2 == 0:
    print(total_sum)
else:
    print(total_sum-minimum_abs*2)

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

abs_a = [abs(i) for i in a]
hu = [i for i in a if i < 0]
hunokazu = len(hu)
zero = 0 in a

if hunokazu%2 == 0 or zero == True:
    print(sum(abs_a))
else:
    abs_a_min = min(abs_a)
    print(sum(abs_a)-abs_a_min*2)

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

Solution (Python):

import sys
N=int(input())
A=list(map(int,input().split()))
neg=0

for a in A:
    if a<0:neg+=1
if neg%2==0:
    print(sum(abs(x) for x in A))
    sys.exit(0)
else:
    m=min(abs(x) for x in A)
    print(sum(abs(x) for x in A) - 2*m)

Solution (Python):
n = int(input())
a = list(map(int, input().split(" ")))
dp = [[0 for i in range(2)] for i in range(n)]

dp[1][0] = a[0] + a[1]
dp[1][1] = -(a[0] + a[1])

for i in range(2, n):
    dp[i][0] = max(dp[i-1][0]+a[i], dp[i-1][1]+a[i])
    dp[i][1] = 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][0], dp[n-1][1]))

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

cnt = len([i for i in A if i < 0])
abs_A = [abs(i) for i in A]

if not cnt%2:
    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()]
abs_a = [abs(x) for x in a]
parity_a = len([x for x in a if x < 0]) % 2

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

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

sub_an = []
count = 0

for i in an:
    sub_an.append(abs(i))

for i in an:
    if i < 0:
        count += 1

sub_an.sort()

if count % 2 == 0:
    ans = sum(sub_an)
else:
    ans = sum(sub_an) - sub_an[0]*2

print(ans)

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

Solution (Python):
n=int(input())
a=[int(i) for i in input().split()]
ans=None
a_pos=[abs(i) for i in a]
a_min=min(a_pos)
a_neg=sum([1 if i<0 else 0 for i in a])
if a_neg%2==0:
    ans=sum(a_pos)
else: ans=sum(a_pos)-2*a_min
print(ans)

Solution (Python):

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

total = 0
minim = 1000000000
num_negs = 0

for a in An:
    is_neg = int(a < 0)
    num_negs += is_neg
    a *= (is_neg * -2 + 1)
    total += a
    minim = minim if minim < a else a
    pass

if num_negs % 2:
    print(total - 2*minim)
else:
    print(total)
    pass

Solution (Python):

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

total = 0
minim = 1000000000
num_negs = 0

for a in An:
    if a < 0:
        num_negs += 1
        a *= -1
        pass
    total += a
    minim = minim if minim < a else a
    pass

if num_negs % 2:
    print(total - 2*minim)
else:
    print(total)
    pass

Solution (Python):
from itertools import *

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

total = 0
minim = 1000000000
num_negs = 0

for a in An:
    if a < 0:
        num_negs += 1
        a *= -1
        pass
    total += a
    minim = min(minim, a)
    pass

if num_negs % 2:
    print(total - 2*minim)
else:
    print(total)
    pass

Solution (Python):
from itertools import *

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

total = 0
minim = 1000000000
num_negs = 0

for a in An:
    if a < 0:
        num_negs += 1
        a *= -1
        pass
    total += a
    minim = min(minim, a)
    pass

if num_negs % 2:
    print(total - 2*minim)
else:
    print(total)
    pass

Solution (Python):
from itertools import *

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

class MyIter:

    def __init__(self, it):
        self.it = it
        self.num_negs = 0
        self.total = 0
        self.minimum = 10**9
        pass

    def __update(self, value):
        self.total += value
        self.minimum = min(self.minimum, value)
        return value

    def __iter__(self):
        for value in self.it:
            if value < 0:
                self.num_negs += 1
                yield self.__update(-value)
                pass
            else:
                yield self.__update(value)
                pass
            pass
        pass

    def to_ans(self):
        if self.num_negs % 2 == 1:
            return self.total - 2 * self.minimum
        else:
            return self.total
        pass

    pass

myiter = MyIter(An)
Bn = list(myiter)

print(myiter.to_ans())

Solution (Python):
from itertools import *

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

class MyIter:

    def __init__(self, it):
        self.it = it
        self.num_negs = 0
        pass

    def __iter__(self):
        for value in self.it:
            if value < 0:
                self.num_negs += 1
                yield -value
                pass
            else:
                yield value
                pass
            pass
        pass

    pass

myiter = MyIter(An)
Bn = list(myiter)
ans = sum(Bn)

if myiter.num_negs % 2 == 1:
    ans -= 2 * min(Bn)
    pass

print(ans)

Solution (Python):
from itertools import *
from collections import *

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

An_pos, An_neg = deque(), deque()
for a in An:
    if a >= 0:
        An_pos.append(a)
    else:
        An_neg.append(-a)
        pass
    pass

ans = sum(chain(An_pos, An_neg))

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

print(ans)

Solution (Python):
from itertools import chain

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

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

ans = sum(An_pos) + sum(An_neg)

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

print(ans)

Solution (Python):

import numpy as np


n = input()
n = int(n)


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

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




l = np.abs(l)

if count % 2 == 0:
    
    print(sum(l))

else:
    print( sum(l) - 2*min(l) )

Solution (Python):


from sys import stdin

input = stdin.readline

N = int(input())
sign = 0
A = list(map(int, input().split()))
for i in range(N):
    if A[i] < 0:
        A[i] = A[i] * (-1)
        sign += 1
result = 0

if sign % 2 == 0:
    result = sum(A)
else:
    result = sum(A) - min(A) * 2

print(result)

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








positive=[]
negative=[]
for a in A:
	if(a>=0):
		positive.append(a)
	else:
		negative.append(a)
if(len(negative)%2==0):
	print(sum(positive)-sum(negative))
else:
	
	if(len(positive)==0):
		print(-sum(negative)+2*max(negative))
	
	else:
		max_nega=max(negative)
		min_posi=min(positive)
		if(-1*max_nega>min_posi):
			print(sum(positive)-sum(negative)-2*min_posi)
		else:	
			print(sum(positive)-sum(negative)+2*max_nega)

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

count = 0
abnum = []

for i in num:
    abnum.append(abs(i))
abnum.sort()

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

if count % 2 == 0:
    ans = sum(abnum)
else:
    ans = sum(abnum)-abnum[0]*2

print(ans)

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

nega_count = 0

for i, v in enumerate(a_list):
    if v < 0:
        nega_count += 1
        a_list[i] = -1*v
a_list
if nega_count % 2 == 0:
    print(sum(a_list))
else:
    print(sum(a_list)-2*min(a_list))

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

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

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

if count % 2 == 0:
    b = sum(li)
else:
    b = sum(li) - li[0] * 2

print(b)

Solution (Python):
def solve():
    N = int(raw_input())
    arr = [int(_) for _ in raw_input().split()]
    neg_cnt = 0
    abs_sum = 0
    min_abs = 10**10
    for i in range(N):
        abs_sum += abs(arr[i])
        if abs(arr[i]) < min_abs:
            min_abs = abs(arr[i])
        if arr[i] < 0:
            neg_cnt += 1
    if neg_cnt % 2 == 0:
        ret = abs_sum
    else:
        ret = abs_sum - 2 * min_abs
    print str(ret)

if __name__ == '__main__':
    solve()

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

k = 0
for t in a:
  if t < 0:
    k += 1
k = k%2

b = [abs(t) for t in a]
b.sort(reverse = 1)

print(sum(b)-2*k*b[-1])

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

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

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

minus = sum(x < 0 for x in A)

absA = list(map(abs,A))
if minus % 2 == 0:
    ans = sum(absA)
else:
    ans = sum(absA) - (2 * min(absA))

print(ans)

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

def count_negative(A):
    count = 0
    for i in range(len(A)):
        if A[i] < 0:
            count += 1
    return count

def find_zero(A):
    for i in range(len(A)):
        if A[i] == 0:
            return True
    return False

def even(x):
    if x % 2 == 0:
        return True
    return False

def flipping_signs(A):
    A_abs = [abs(x) for x in A]
    sum_A_abs = sum(A_abs)
    if even(count_negative(A)) or find_zero(A):
        print(sum_A_abs)
    else:
        A_abs_min = min(A_abs)
        print(sum_A_abs - 2 * A_abs_min)

flipping_signs(A)

Solution (Python):
n = int(input())
a = list(map(int, input().split()))
box = []
count = 0
zero = 0
for num in range(n):
    box.append(abs(a[num]))
for num in a:
    if num < 0:
        count += 1
    elif num == 0:
        zero += 1
box.sort()

if count % 2 == 0 or zero > 0:
    print(sum(box))
else:
    box[0] = -box[0]
    print(sum(box))

Solution (Python):
N = int(input())
A = list(map(int, input().split()))
sign = []
for i in range(N):
    sign.append(A[i] > 0)
if sign.count(False) % 2 == 0:
    result = 0
    for i in range(N):
        result += abs(A[i])
else:
    result = 0
    for i in range(N):
        result += abs(A[i])
    result -= 2 * min(list(map(abs, A)))
print(result)

Solution (Python):
l = int(input())
tmp = list(map(int, input().split()))
lst = list(map(lambda x: x if x > 0 else x*-1, tmp))

minus = list(filter(lambda x: x < 0, tmp))

ans = 0
if len(minus) % 2 == 0:
    ans = sum(lst)
else:
    ans = sum(lst) - (abs(min(lst))*2)

print(ans)

Solution (Python):
N = int(input())
a = [int(i) for i in input().split()]
cnt = 0
s = 0
smallest = 10000000000
for i in range(len(a)):
    if a[i] < 0:
        cnt += 1

    smallest = min(abs(a[i]), smallest)
    s += abs(a[i])

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

Solution (Python):
MAX = 10**9
N = int(input())
A = list(map(int,input().split()))

cnt = 0
a_abs_min = MAX
s = 0
for a in A:
    s += abs(a)
    if a < 0:
        cnt += 1
    if abs(a_abs_min) > abs(a):
        a_abs_min = a

if cnt%2 == 1:
    s -= abs(a_abs_min)*2

print(s)

Solution (Python):
N = int(input())
A = [int(a) for a in input().split()]
prev0, prev1 = (A[0], -A[0])
for i in range(N-2):
    curr0 = max(prev0+A[i+1], prev1-A[i+1])
    curr1 = max(prev0-A[i+1], prev1+A[i+1])
    prev0, prev1 = (curr0, curr1)
print(max(prev0+A[-1], prev1-A[-1]))

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

Solution (Python):
N = int(input())
A = list(map(int,input().split()))
tmp = 10**9
sum = 0
numFu = 0

for i in range(N):
    if A[i] < 0:
        numFu += 1
    sum += abs(A[i])
    tmp = min(tmp,abs(A[i]))

if numFu % 2 == 0:
    print(sum)
else:
    print(sum - 2*tmp)

Solution (Python):
N = int(input())
A = list(map(int,input().split()))
po = []
ne = []
for i in range(N):
    if A[i] < 0:
        ne.append(A[i])

A = list(map(abs,A))
A.sort()
if len(ne) != 0:
    if len(ne) % 2 == 0:
        print(sum(A))
    else:
        print(sum(A)-2*A[0])
else:
    print(sum(A))

Solution (Python):
N = int(input())
A = list(map(int,input().split()))
minabs = 10**9
i = 0
j = N-1
sum = 0
while i < j:
    while A[i] > 0 and i < j:
        if A[i] < minabs:
            minabs = A[i]
        sum += A[i]
        i += 1
        

    if i == j:
        break

    
    

    while A[j] > 0 and i < j:
        if A[j] < minabs:
            minabs = A[j]
        sum += A[j]
        j -= 1
        
    if i == j:
        break


    if -A[i]< minabs:
        minabs = -A[i]
    
    sum -= A[i]
    i += 1
    
    if -A[j] < minabs:
        minabs = -A[j]
    sum -= A[j]
    j -= 1
    
if i == j:
    if A[i] < 0:
        sum -= A[i]
        
        sum -= minabs*2
        
    else:
        sum += A[i]
        
print(sum)

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

Solution (Python):

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










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

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

cnt = len([i for i in A if i < 0])
abs_A = sorted([abs(i) for i in A])

if cnt%2 == 0:
    print(sum(abs_A))
else:
    print(sum(abs_A)-2*abs_A[0])

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

num_minus = [1 if i<0 else 0 for i in a]
abs_list = [abs(i) for i in a]

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

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(abs(a[i]))
b.sort()
sb = sum(b)
if m % 2 == 0:
    print(sb)
else:
    print(sb-b[0]*2)

Solution (Python):

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

dp = [[0] * 2 for _ in range(N)]
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]))

Solution (Python):
N = int(input())
integers = [int(n) for n in input().split()]
absolute_integers = [abs(n) for n in integers]

negatives = [n for n in integers if n < 0]

if 0 in integers:
    result = sum(absolute_integers)
elif len(negatives)%2 == 0:
    result = sum(absolute_integers)
else:
    result = sum(absolute_integers) -2 * min(absolute_integers)

print(result)

Solution (Python):

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

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

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

print(max(dp[N - 2]))

Solution (Python):

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

total = sum(abs(x) for x in A)
neg_num = len([x for x in A if x < 0])

if neg_num % 2 == 1:
    min_num = min(abs(x) for x in A)
    total -= min_num * 2

print(total)

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

dp = [[0, float("-inf")] for i in range(n+1)]

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()))
count = 0
for i in range(n):
    if A[i]<0:
        A[i] = -A[i]
        count += 1
if count % 2 == 1:
    print(sum(A)-2*min(A))
else:
    print(sum(A))

Solution (Python):
from sys import stdin
import numpy as np

import fractions as math





N = int(stdin.readline().rstrip().split()[0])
A = [int(x) for x in stdin.readline().rstrip().split()]
A = np.array(A)
abs_A = abs(A)
posi = sum(A<0)
if posi%2==0:
  print(sum(abs_A))
else:
  minA = min(abs_A)
  print(sum(abs_A)-2*minA)

Solution (Python):

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

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


ans = (
    sum(C) if sum(a < 0 for a in A) % 2 == 0 else
    sum(C) - 2 * min(C)
)


print(ans)

Solution (Python):



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

minabs = 10**9
sumabs = 0
minusnum = 0

for i in range(n):
    num = lista[i]
    if num < 0:
        minusnum += 1
    if abs(num)<minabs:
        minabs = abs(num)
    sumabs += abs(num)
    
if minusnum%2 == 0:
    print(sumabs)
else:
    print(sumabs - 2*minabs)

Solution (Python):

n = int(input())
as_ = tuple(int(i) for i in input().split())



maxb = sum(abs(a) for a in as_)


if [a < 0 for a in as_].count(True) % 2 == 0:
    
    pass
else:
    
    smallest = min(abs(a) for a in as_)
    maxb -= smallest * 2

print(maxb)

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

flag = 0
count = 0

for i in range(N):
    if(A[i] == 0):
        flag = 1

    if(flag == 0):
        if(A[i] < 0):
            count += 1

    A[i] = abs(A[i])

if(count % 2 == 0):
    flag = 1


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

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

flag = 0

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

if(A[N - 1] > 0):
    flag = 1

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

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

Solution (Python):
from sys import stdin

N = int(stdin.readline().rstrip())
data = stdin.readline().rstrip().split()

abs_sum = 0
negative_elements = []
zero_exist = False

for number in data:
    num = int(number)
    abs_sum += abs(num)
    if num == 0:
        zero_exist = True
    elif num < 0:
        negative_elements.append(int(num))

if len(negative_elements) % 2 == 0 or zero_exist:
    print(abs_sum)
else:
    print(abs_sum - (2 * min([abs(int(x)) for x in data])))

Solution (Python):
from sys import exit

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

dp = [[0] * 2 for i in range(N + 1)]
dp[0][0] = 0
dp[0][1] = -10 ** 6

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][1] + A[i], dp[i][0] - A[i])

print(dp[N][0])

Solution (Python):
from sys import exit

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

zero = False
negative_num = 0
min_num = abs(A[0])

for a in A:
    if a == 0:
        zero = True
        break

    if a < 0:
        negative_num += 1

    if abs(a) < min_num:
        min_num = abs(a)

ans = 0

if zero or (negative_num % 2 == 0):
    for a in A:
        ans += abs(a)
else:
    for a in A:
        ans += abs(a)
    ans -= min_num * 2

print(ans)

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

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

INF = 10**6

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

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

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

dp[0][1] = - 10 ** 18

for i in range(N):
    for j in range(2):
        if j == 0:
            dp[i+1][j] = max(dp[i][0] + A[i], dp[i][1] - A[i])
        else:
            dp[i+1][j] = 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()))

neg = 0
for i in range(N):
  if A[i]<0:
    A[i]=-A[i]
    neg+=1
    
if (neg % 2) == 0:
  print(sum(A))
else:
  print(sum(A)-2*min(A))

Solution (Python):


def main():
  if 'get_ipython' not in globals():  
    
    N = int(input())
    
    A = [int(i) for i in input().split()] 
    
    
    
    
    
    
  else:
    
    
    A = [-1000000000,1000000000,-1000000000,1000000000,-1000000000,0,1000000000,-1000000000,1000000000,-1000000000,1000000000]
    N = len(A)

  
  
  sumA = 0
  min_abs = 1000000000
  cnt_minus = 0
  for a in A:
    if a < 0 :
      cnt_minus +=1
    if abs(a) < min_abs: 
      min_abs = abs(a)
    sumA += abs(a)
  
  if cnt_minus % 2 > 0:
    sumA -= min_abs * 2
  
  print(sumA)

main()

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

minv = -1
count = 0
s = 0
for i in range(n):
    if a[i] < 0:
        s += -a[i]
        if minv > -a[i] or minv == -1:
            minv = -a[i]
        count += 1
    else:
        s += a[i]
        if minv > a[i] or minv == -1:
            minv = a[i]

if count % 2 == 1:
    s += 2*(-minv)

print(s)