CodeEff/ECCO huggingface dataset:
# Original solution
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2, gcd
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(eval(input()))
def MAP(): return list(map(int, input().split()))
def LIST(): return list(map(int, input().split()))
def ZIP(n): return list(zip(*(MAP() for _ in range(n))))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7 
#mod = 998244353
from decimal import *
#import numpy as np
#decimal.getcontext().prec = 10

N = INT()
A = LIST()

cnt = 0
for i, x in enumerate(A):
	if x < 0:
		cnt += 1
		A[i] *= -1

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


# Optimized solution
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2, gcd
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(eval(input()))
def MAP(): return list(map(int, input().split()))
def LIST(): return list(map(int, input().split()))
def ZIP(n): return list(zip(*(MAP() for _ in range(n))))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7 
#mod = 998244353
from decimal import *
#import numpy as np
#decimal.getcontext().prec = 10

N = INT()
A = LIST()
a = [abs(x) for x in A] #Aの絶対値

n = sum([A[i] != a[i] for i in range(N)]) #Aの中で負のものは何個あるか

if n%2:
	print((sum(a) - 2*min(a)))
else:
	print((sum(a)))
# Original solution
n = int(eval(input()))
a = list(map(int,input().split()))
aabs = [i if i>=0 else i*(-1) for i in a]
MIN = min(aabs)
ans = 0
mcount = 0

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

# Optimized solution
#他の数字はそのままで，任意の2数の符号を同時に反転させることが可能．マイナスの数の偶奇で場合分け
n = int(eval(input()))
a = list(map(int,input().split()))
aabs = [i if i>=0 else i*(-1) for i in a]
MIN = min(aabs)
ans = 0
mcount = 0

for i in range(n):
  if a[i] < 0:
    mcount += 1
    
if mcount%2 == 0:
  for i in a:
    ans += abs(i)
  print(ans)
else:
  for i in a:
    ans += abs(i)
  print((ans - 2*MIN))
# Original solution
def main():
    _ = int(eval(input()))
    A = [int(i) for i in input().split()]
    cnt_minus = 0
    zero_flag = False
    for i, a in enumerate(A):
        if a < 0:
            cnt_minus += 1
        elif a == 0:
            zero_flag = True

    ans = 0
    if cnt_minus % 2 == 0 or zero_flag:
        ans = sum(abs(a) for a in A)
    else:
        ans = sum(abs(a) for a in A) - min(abs(a) for a in A) * 2
    print(ans)


if __name__ == '__main__':
    main()


# Optimized solution
def main():
    import sys
    input = sys.stdin.buffer.readline
    _ = int(eval(input()))
    A = [int(i) for i in input().split()]
    sumA = sum(abs(a) for a in A)
    mi = len([a for a in A if a < 0])
    if 0 in A or mi % 2 == 0:
        print(sumA)
    else:
        print((sumA - 2*min(abs(a) for a in A)))


if __name__ == '__main__':
    main()
# Original solution
N = int(eval(input()))
arr = list(map(int, input().split()))
count = 0
gokei = 0
mi = float('inf')
flg = False
for i in arr:
    gokei += abs(i)
    mi = min(mi,abs(i))
    if i < 0:
        count += 1
    if i == 0:
        flg = True
if flg or count % 2 == 0:
    print(gokei)
else:
    print((gokei-mi*2))

# Optimized solution
N = int(eval(input()))
arr = list(map(int, input().split()))
cnt = 0
flg = False
for i in range(N):
    if arr[i] == 0:
        flg = True
    if arr[i] < 0:
        cnt += 1
    arr[i] = abs(arr[i])
if cnt % 2 == 0 or flg:
    print((sum(arr)))
else:
    print((sum(arr) - min(arr)*2))
# Original solution
n = int(eval(input()))
a = [int(i) for i in input().split()]
sum_abs, min_abs, cnt_minus = 0, 10**9, 0
for ai in a:
    if ai < 0:
        cnt_minus += 1
    abs_ai = abs(ai)
    sum_abs += abs_ai
    if abs_ai < min_abs:
        min_abs = abs_ai
if cnt_minus % 2 == 0 or 0 in a:
    print(sum_abs)
else:
    print((sum_abs - 2*min_abs))

# Optimized solution
# knk_kei  0 in a の条件は不要 
n = int(eval(input()))
a = [int(i) for i in input().split()]
if len([i for i in a if i < 0]) % 2 == 0:
    print((sum([abs(i) for i in a])))
else:
    print((sum([abs(i) for i in a]) - 2*min([abs(i) for i in a])))
# Original solution
n = int(eval(input()))
a = list(map(int, input().split()))
pa = []
cnt = 0
for s in a:
    if s < 0:
        cnt += 1
    pa.append(abs(s))
if cnt % 2:
    print((sum(pa) - 2 * min(pa)))
else:
    print((sum(pa)))
    

# Optimized solution
n = int(eval(input()))
a = list(map(int, input().split()))
pa = [abs(s) for s in a]
cnt = sum([s < 0 for s in a])
if cnt % 2:
    print((sum(pa) - 2 * min(pa)))
else:
    print((sum(pa)))
# Original solution
N = int(eval(input()))
A = list(map(int, input().split()))

negA = []
posA = []
for a in A:
    if a >= 0:
        posA.append(a)
    else:
        negA.append(a)

ans = sum(posA) - sum(negA)

if len(negA) % 2 == 1:
    ans -= min([abs(a) for a in A]) * 2

print(ans)


# Optimized solution
N = int(eval(input()))
A = list(map(int, input().split()))
B = [abs(a) for a in A]

minus = sum([a < 0 for a in A])
ans = sum(B)

if minus % 2 == 1:
    ans -= min(B) * 2

print(ans)
# Original solution
N=int(eval(input()))
A=list(map(int,input().strip().split(' ')))

dp=[[0]*2 for i in range(len(A))]


dp[0][0]=A[0]
dp[0][1]=A[0]

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

# Optimized solution
eval(input())
A=list(map(int,input().strip().split(" ")))
pos=[]
neg=[]
for x in A:
    if x>=0:
        pos+=[x]
    else:
        neg+=[x]

pos=sorted(pos)
neg=sorted(neg)

if len(neg)%2==0:
    print((sum(pos)-sum(neg)))
else:
    ans1=sum(pos)-sum(neg)+2*neg[-1]
    ans2=sum(pos)-sum(neg)+2*neg[-1]
    if len(pos)>0:
        ans2=sum(pos)-sum(neg)-2*pos[0]
    print((max(ans1,ans2)))
# Original solution
n=int(eval(input()))

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

count = 0

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

memo = []

for i in t:
    memo.append(abs(i))
memo.sort()

if count%2==0:
    print((sum(memo)))
else:
    print((sum(memo)-memo[0]*2))

# Optimized solution
n=int(eval(input()))

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

plus = []

minas = []

for value in a:
    if value < 0:
        minas.append(abs(value))
    else:
        plus.append(value)

if len(minas)%2 == 0:
    ans = sum(plus)+sum(minas)
else:
    if len(plus) > 0:
        mini = min(min(plus),min(minas))
        ans = sum(plus)+sum(minas)-mini*2
    else:
        mini = min(minas)
        ans = sum(minas)-mini*2

print(ans)
# Original solution
n = int(eval(input()))
a = list(map(int, input().split()))
new_a = []
sum = 0
minus_count = 0
zero_flag = 0

for i in range(n):
	new_a.append(abs(a[i]))

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

if zero_flag == 1:
	for i in range(n):
		sum += abs(a[i])
elif minus_count % 2 == 0:
	for i in range(n):
		sum += abs(a[i])
else:
	for i in range(n):
		sum += new_a[i]
	sum = sum - min(new_a) * 2

print(sum)

# Optimized solution
n = int(eval(input()))
a = list(map(int, input().split()))
new_a = []
sum = 0
minus_count = 0

for i in range(n):
	new_a.append(abs(a[i]))

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

if minus_count % 2 == 0:
	for i in range(n):
		sum += abs(a[i])
else:
	for i in range(n):
		sum += new_a[i]
	sum = sum - min(new_a) * 2

print(sum)
# Original solution
import sys

sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    n = int(eval(input()))
    A = list(map(int, input().split()))

    cnt = 0
    total = 0
    mi = f_inf
    for a in A:
        total += abs(a)
        if a < 0:
            cnt += 1
        if mi > abs(a):
            mi = abs(a)

    if cnt % 2 == 0:
        print(total)
    else:
        print((total - mi * 2))


def resolve2():
    n = int(eval(input()))
    A = list(map(int, input().split()))

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

    print((dp[n][0]))


if __name__ == '__main__':
    resolve2()


# Optimized solution
import sys

sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    n = int(eval(input()))
    A = list(map(int, input().split()))
    total = 0
    mi = f_inf
    cnt_minus = 0
    for a in A:
        if a < 0:
            cnt_minus += 1
        if mi > abs(a):
            mi = abs(a)
        total += abs(a)
    print((total if cnt_minus % 2 == 0 else total - mi * 2))


if __name__ == '__main__':
    resolve()
# Original solution
n = int(eval(input()))
lis = list(map(int, input().split()))

if 0 in lis:
    ans = 0
    for i in lis:
        if i < 0:
            ans += -1 * i
        else:
            ans += i
    print(ans)
    exit()

minus = [0]*n
for i in range(n):
    if lis[i] < 0:
        minus[i] = 1

if sum(minus) % 2 == 0:
    ans = 0
    for i in lis:
        if i < 0:
            ans += -1 * i
        else:
            ans += i
    print(ans)
else:
    ans = 0
    m = 10**9+1
    for i in lis:
        if i < 0:
            ans += -1*i
        else:
            ans += i
        m = min(m, abs(i))
    print((ans - 2*m))


# Optimized solution
n = int(eval(input()))
lis = list(map(int, input().split()))

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

if 0 in lis or minus % 2 == 0:
    print((sum(lis)))
else:
    print((sum(lis) - 2*min(lis)))
# Original solution
n=int(eval(input()))
l=list(map(int,input().split()))
a=abs(l[0])
m=0
d=0
z=0
s=0
for i in range(n):
  if l[i]<0:
    d+=1
  elif l[i]==0:
    z+=1
if d%2==0 or (d+z)%2==0:
  for i in range(n):
    s+=abs(l[i])
  print(s)
else:
  for i in range(1,n):
    if a>=abs(l[i]):
      a=abs(l[i])
      m=i
  s=0
  for i in range(m):
    s+=abs(l[i])
  s+=-abs(l[m])
  for i in range(m+1,n):
    s+=abs(l[i])
  print(s)
    

# Optimized solution
n=int(eval(input()))
l=list(map(int,input().split()))
b=False
sum=0
count=0
absmin=10000000
for i in l:
  if i==0:
    b=True
  elif i<0:
    count+=1
  if absmin>abs(i):
    absmin=abs(i)
  sum+=abs(i)
if b:
  print(sum)
else:
  if count%2==1:
    print((sum-2*absmin))
  else:
    print(sum)
# Original solution
N=int(eval(input()))
L=list(map(int,input().split()))
count=0
sum=0
A=float("inf")
for i in L:
	sum+=abs(i)
	A=min(A,abs(i))
	if i<0:
		count+=1
if count%2==0:
	print(sum)
else:
	print((sum-A*2))

# Optimized solution
N=int(eval(input()))
L=list(map(int,input().split()))
count=0
sum=0
A=float("inf")
for i in L:
	sum+=abs(i)
	A=min(A,abs(i))
	if i<0:
		count+=1
if count%2==0:
	print(sum)
else:
	B=float("inf")
	for i in L:
		if abs(i)==A:
			if i==0:
				print(sum)
				exit()
			elif i>0:
				print((sum-2*i))
				exit()
			elif i<0:
				print((sum-2*A))
				exit()
# Original solution
N=int(eval(input()))
L=list(map(int,input().split()))
count=0
sum=0
A=float("inf")
for i in L:
	sum+=abs(i)
	A=min(A,abs(i))
	if i<0:
		count+=1
if count%2==0:
	print(sum)
else:
	B=float("inf")
	for i in L:
		if abs(i)==A:
			if i==0:
				print(sum)
				exit()
			elif i>0:
				print((sum-2*i))
				exit()
			elif i<0:
				print((sum-2*A))
				exit()

# Optimized solution
N=int(eval(input()))
L=list(map(int,input().split()))
count=0
sum=0
A=float("inf")
for i in L:
	sum+=abs(i)
	A=min(A,abs(i))
	if i<0:
		count+=1
if count%2==0:
	print(sum)
else:
	print((sum-A*2))
# Original solution
N = int(eval(input()))
A = list(map(int,input().split()))

cnt = len([1 for i in range(N) if A[i] < 0])
SUM = sum(map(abs,A))
MIN = min(list(map(abs,A)))

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

# Optimized solution
N=int(eval(input()))
A=list(map(int,input().split()))
print((sum(map(abs,A))-2*min(list(map(abs,A)))*(sum([1 for i in A if i<0])%2)))
# Original solution
N = int(eval(input()))
A = list(map(int,input().split()))

minus_cnt = 0
abs_sum = 0
min_abs_val = 1000000000
for i in range(N):
    abs_val = abs(A[i])
    abs_sum = abs_sum + abs_val
    if abs_val < min_abs_val:
        min_abs_val = abs_val
    if A[i] < 0:
        minus_cnt = minus_cnt + 1

B_max_sum = 0
if (minus_cnt % 2 == 0) or (min_abs_val == 0):
    B_max_sum = abs_sum
else:
    B_max_sum = abs_sum - min_abs_val * 2

print(B_max_sum)


# Optimized solution
N = int(eval(input()))
A = list(map(int,input().split()))

minus_cnt = 0
abs_sum = 0
min_abs_val = 1000000000
for i in range(N):
    val = A[i]
    abs_val = abs(val)
    abs_sum += abs_val
    if abs_val < min_abs_val:
        min_abs_val = abs_val
    if val < 0:
        minus_cnt += 1

B_max_sum = abs_sum
if (minus_cnt % 2 != 0) and (min_abs_val != 0):
    B_max_sum -= (min_abs_val * 2)

print(B_max_sum)
# Original solution
N=int(eval(input()))
A=[int(i) for i in input().split()]
plus=0
zero=0
minus=0
for i in A:
    if i>0:
        plus+=1
    elif i==0:
        zero+=1
    else:
        minus+=1

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


# Optimized solution
N=int(eval(input()))
A=[int(i) for i in input().split()]
B=[abs(i) for i in A]
minus=0
for i in A:
    if i<0:
        minus+=1
if minus%2==0:
    print((sum(B)))
else:
    print((sum(B)-2*min(B)))
# Original solution
def solve():
    n = int(eval(input()))
    a = list(map(int, input().split()))

    dp = [[-1] * 2 for _ in range(n + 1)]
    dp[0][False] = 0
    # dp[idx][マイナスをかける必要があるか]:=総和の最大値

    for j, x in enumerate(a):
        if dp[j][True] == -1:
            dp[j + 1][False] = dp[j][False] + x
            dp[j + 1][True] = dp[j][False] - x
        else:
            dp[j + 1][False] = max(dp[j][False] + x, dp[j][True] - x)
            dp[j + 1][True] = max(dp[j][False] - x, dp[j][True] + x)
    return dp[n][False]


if __name__ == '__main__':
    print((solve()))


# Optimized solution
def main():
    inf = 10 ** 14 + 1

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

    stay = 0  # -1を乗算しない
    done = -inf  # -1を乗算した

    for x in a:
        stay, done = max(stay + x, done - x), max(stay - x, done + x)

    print(stay)


if __name__ == '__main__':
    main()
# Original solution
from itertools import *
from collections import *

N = int(eval(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)


# Optimized solution
from itertools import *

N = int(eval(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)
# Original solution
from itertools import *

N = int(eval(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()))


# Optimized solution
from itertools import *

N = int(eval(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
# Original solution
from itertools import *

N = int(eval(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


# Optimized solution

N = int(eval(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 = minim if minim < a else a
    pass

if num_negs % 2:
    print((total - 2*minim))
else:
    print(total)
    pass
# Original solution
n=eval(input())
a=list(map(int,input().split()))
n=sum(x<0 for x in a)
a=list([abs(x) for x in a])
s=sum(a) if n%2==0 else sum(a)-min(a)*2
print(s)


# Optimized solution
n=eval(input())
a=list(map(int,input().split()))
n=sum(x<0 for x in a)
a=list(map(abs,a))
s=sum(a) if n%2==0 else sum(a)-min(a)*2
print(s)
# Original solution
n = int(eval(input()))
a = list(map(int,input().split()))
minus_num = 0
for i in range(n):
    if a[i] < 0:
        minus_num += 1
if minus_num % 2 == 0:
    ans = 0
    for i in range(n):
        ans += abs(a[i])
else:
    min_abs = abs(a[0])
    ans = 0
    for i in range(n):
        ans += abs(a[i])
        min_abs = min(min_abs, abs(a[i]))
    ans = ans - min_abs * 2
print(ans)


# Optimized solution
n = int(eval(input()))
a = list(map(int,input().split()))
cnt = 0
for i in range(n):
    if a[i] < 0:
        cnt += 1
ans = 0
if cnt % 2 == 0:
    for i in range(n):
        ans += abs(a[i])
    print(ans)
else:
    tar = abs(a[0])
    for i in range(n):
        ans += abs(a[i])
        if tar > abs(a[i]):
            tar = abs(a[i])
    print((ans-2*tar))
# Original solution
import sys
sys.setrecursionlimit(10**5)

n = int(eval(input()))
a = list(map(int, input().split()))
# dp = [None]*(n+1)
#dp = [[None]*(n+1) for _ in range(2)]
dp = [[None]*(2) for _ in range(n+1)]

def solve(a):
    if len(a) == 0:
        return 0
    elif len(a) == 1:
        return a[0]
    elif len(a) == 2:
        v1 = a[0] + a[1]
        v2 = -a[0] - a[1]
        return max(v1, v2)

    v1 = a[0] + solve(a[1:])
    v2 = -a[0] + solve([-a[1]] + a[2:])
    return max(v1, v2)

def solve(a, flg):
    l = len(a)
    if dp[l][flg] is not None:
        return dp[l][flg]

    if flg == 1:
        a[0] = -a[0]

    if l == 0:
        dp[l][flg] = 0
    elif l == 1:
        dp[l][flg] = a[0]
    elif l == 2:
        v1 = a[0] + a[1]
        v2 = -a[0] - a[1]
        dp[l][flg] = max(v1, v2)
    else:
        v1 = a[0] + solve(a[1:], 0)
        v2 = -a[0] + solve(a[1:], 1)
        dp[l][flg] = max(v1, v2)
        # if flg == 0:
        #     v1 = a[0] + solve(a[1:], flg)
        #     v2 = -a[0] + solve(a[1:], abs(flg - 1))
        #     dp[l][flg] = max(v1, v2)
        # else:
        #     v1 = -a[0] + solve(a[1:], flg)
        #     v2 = a[0] + solve(a[1:], abs(flg - 1))
        #     dp[l][flg] = max(v1, v2)

    return dp[l][flg]

#def solve(idx):
print((solve(a, 0)))
#print(solve(a, 1))
#print(solve(a, 0))
# v1 = solve(a, 1)
# v2 = solve(a, 0)
#
# print(v1, v2)
# print(max(v1, v2))


# Optimized solution
import sys
sys.setrecursionlimit(10**5)

n = int(eval(input()))
a = list(map(int, input().split()))
dp = [[None]*(2) for _ in range(n+1)]

dp[n-1][0] = a[n-1]
dp[n-1][1] = -a[n-1]

for i in reversed(list(range(n-1))):
    for j in range(2):
        #print('\n# i: ' + str(i))
        # Unexe
        unexe_unexe = a[i] + dp[i+1][0]
        exe_unexe = -a[i] + dp[i+1][1]
        dp[i][0] = max(unexe_unexe, exe_unexe)

        # Exe
        unexe_exe = a[i] + dp[i+1][1]
        exe_exe = -a[i] + dp[i+1][0]
        dp[i][1] = max(unexe_exe, exe_exe)

#print(dp)
#print(max(dp[0][0], dp[0][1]))
print((dp[0][0]))
# Original solution
N = int(eval(input()))
A = [int(i) for i in input().split()]

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

print((dp[N][0]))

# Optimized solution
N = int(eval(input()))
A = [int(i) for i in input().split()]

a, b = 0, -1e10
for ai in A:
    a, b = max(a + ai, b - ai), max(a - ai, b + ai)

print(a)
# Original solution
N = int(eval(input()))
A = [int(i) for i in input().split()]

a, b = 0, -1e10
for ai in A:
    a, b = max(a + ai, b - ai), max(a - ai, b + ai)

print(a)

# Optimized solution
N = int(eval(input()))
A = [int(i) for i in input().split()]

B = [abs(a) for a in A]
if len([a for a in A if a < 0]) % 2 == 1:
    print((sum(B) - 2 * min(B)))
else:
    print((sum(B)))
# Original solution
N = int(eval(input()))
A = [int(a) for a in input().split()]
DP = [[None, None] for i in range(N)] 
DP[0] = [A[0], -A[0]]
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])
print((DP[N-1][0]))


# Optimized solution
import sys

def solve():
    input = sys.stdin.readline
    N = int(eval(input()))
    A = [int(a) for a in input().split()]
    DP = [[-10 ** 20] * 2 for _ in range(N)]
    DP[0][0] = A[0]
    DP[0][1] = -1 * A[0]
    for i in range(1, N):
        a = A[i]
        DP[i][0] = max(max(DP[i-1][0] + a, DP[i-1][1] - a), DP[i][0])
        DP[i][1] = max(max(DP[i-1][0] - a, DP[i-1][1] + a), DP[i][1])

    print((DP[N-1][0]))

    return 0

if __name__ == "__main__":
    solve()
# Original solution
import sys

def solve():
    input = sys.stdin.readline
    N = int(eval(input()))
    A = [int(a) for a in input().split()]
    DP = [[-10 ** 20] * 2 for _ in range(N)]
    DP[0][0] = A[0]
    DP[0][1] = -1 * A[0]
    for i in range(1, N):
        a = A[i]
        DP[i][0] = max(max(DP[i-1][0] + a, DP[i-1][1] - a), DP[i][0])
        DP[i][1] = max(max(DP[i-1][0] - a, DP[i-1][1] + a), DP[i][1])

    print((DP[N-1][0]))

    return 0

if __name__ == "__main__":
    solve()

# Optimized solution
import sys

def solve():
    input = sys.stdin.readline
    N = int(eval(input()))
    A = [int(a) for a in input().split()]
    DP = [[-10 ** 20, -10 ** 20] for _ in range(N)] #[-1が偶数, -1が奇数]
    DP[0] = [A[0], -1 * A[0]]
    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])
    print((DP[N-1][0]))
    #print(DP)


    return 0

if __name__ == "__main__":
    solve()