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

Solution (Python):




def solve():
    N = int(input())
    A = list(map(int, input().split()))
    ret = sum(abs(a) for a in A)
    num_neg = sum(a < 0 for a in A)
    min_abs_A = min(abs(a) for a in A)
    if num_neg % 2 == 1:
        ret -= 2*min_abs_A
        
    print(ret)
    
solve()

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

N = int(input())
A = list(map(int,input().split()))
cnt = 0
for i,a in enumerate(A):
    if a<0:
        cnt += 1
        A[i] = -1*a
A = sorted(A)
print(sum(A)-2*A[0]*(cnt%2))

Solution (Python):
from bisect import bisect_left

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

idx = bisect_left(A,0)
if idx != 0 and idx != N:
  if idx % 2 == 1:
    if abs(A[idx-1]) > abs(A[idx]):
      A[idx-1] *= -1
      A[idx] *= -1
  for i in range(0,idx-1,2):
    A[i] *= -1
    A[i+1] *= -1

if idx==N:
  if N % 2 == 0:
    print(-sum(A))
    exit()
  else:
    print(-sum(A[:-1])+A[-1])
    exit()

print(sum(A))

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

sum = 0
pm = 0
min = 10**10
for xi in range(n):
    if a[xi]<0: pm+=1
    sum += abs(a[xi])
    if abs(a[xi])<min :min=abs(a[xi])
    

if pm%2 ==1: sum-=min*2

print(sum)

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

dp1 = [A[0]]
dp2 = [-A[0]]
for i in range(1, N-1):
    dp1.append(max(dp1[i-1] + A[i], dp2[i-1] - A[i]))
    dp2.append(max(dp1[i-1] - A[i], dp2[i-1] + A[i]))
dp1.append(dp1[-1] + A[N-1])
dp2.append(dp2[-1] - A[N-1])


print(max(dp1[-1], dp2[-1]))

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

Solution (Python):
n = int(input())
la = [int(w) for w in input().split()]

ans = sum([abs(w)for w in la])
if len([w for w in la if w < 0]) % 2 == 0:
    print(ans)
    exit()

sla = sorted([abs(w)for w in la])
ans -= sla[0]*2
print(ans)

Solution (Python):





import math
import fractions
import sys
import bisect
import heapq  
import collections
from collections import Counter
from collections import deque
import pprint
import itertools

sr = lambda: input()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

"""nを素因数分解"""
"""2以上の整数n => [[素因数, 指数], ...]の2次元リスト"""


def factorization(n):
    arr = []
    temp = n
    if n == 1:
        return arr

    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 power(a, n, mod):
    x = 1
    while n:
        if n & 1:
            x *= a % mod
        n >>= 1
        a *= a % mod
    return x % mod



def kaijo(n, l, mod):
    if n == 0:
        return 1
    a = n
    tmp = n - 1
    while (tmp >= l):
        a = a * tmp % mod
        tmp -= 1
    return a


class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

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

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())


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)

    divisors.sort()
    return divisors


inf = 10 ** 18
mod = 10 ** 9 + 7

n = ir()
a = lr()
dp = [[0 for  j in range(2)] for i in range(n+1)]
dp[1][1] = -a[0]
dp[1][0] = a[0]
for i in range(1,n-1):
    dp[i+1][1] = max(dp[i][0]-a[i], dp[i][1]+a[i])
    dp[i+1][0] = max(dp[i][0]+a[i], dp[i][1]-a[i])
print(max(dp[n-1][1]-a[n-1], dp[n-1][0]+a[n-1]))

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

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

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

Solution (Python):
n=int(input())
l=[*map(int,input().split())]
c=0
for e,i in enumerate(l):
  if i<0:
    c+=1
    l[e]=-i
print(sum(l)-[0,min(l)*2][c%2])

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

Solution (Python):
n=int(input())
a=[*map(int,input().split())]
b=c=0
l=[]
for i in a:
  if i==0:
    b=1
  if i<0:
    c+=1
  l.append(abs(i))
print(sum(l)-[0,min(l)*2][c%2 and b<1])

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

Solution (Python):
N=int(input())
A=list(map(int,input().split()))
dp=[[0]*2 for i in range(N+1)]
dp[0][1]=-10**30
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):
N = int(input())
A = list(map(int,input().split()))



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

dp[0][False] = None
dp[0][True] = None
dp[1][False] = A[0] + A[1]
dp[1][True] = (A[0] + A[1]) * (-1)

for i in range(2, len(dp)):
  dp[i][False] = max(dp[i - 1][False] + A[i], dp[i - 1][True] + A[i])
  dp[i][True] = max(dp[i - 1][False] - A[i - 1] * 2 - A[i], dp[i - 1][True] + A[i - 1] * 2 - A[i])

print(max(dp[N - 1][False], dp[N - 1][True]))

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

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

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

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

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

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

Solution (Python):
N = int(input())
A = list(map(int, input().split()))
S = sum(map(abs, A))
 
cnt = 0
 
for a in A:
    if a > 0:
        cnt += 1
        
if (len(A)-cnt)%2==0 or 0 in A:
    print(S)
else:
    print(S-2*min(map(abs, A)))

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

count = 0
min = abs(A[0])
sum = 0
for i in A:
    
    if i<=0:
        count += 1
    
    if min > abs(i):
        min = abs(i)
    
    sum += abs(i)



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

Solution (Python):
import sys

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


def resolve():
    n = int(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()

Solution (Python):





import math
import fractions
import sys
import bisect
import heapq  
import collections
from collections import Counter
from collections import deque
import pprint
import itertools

sr = lambda: input()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

"""nを素因数分解"""
"""2以上の整数n => [[素因数, 指数], ...]の2次元リスト"""


def factorization(n):
    arr = []
    temp = n
    if n == 1:
        return arr

    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 power(a, n, mod):
    x = 1
    while n:
        if n & 1:
            x *= a % mod
        n >>= 1
        a *= a % mod
    return x % mod



def kaijo(n, l, mod):
    if n == 0:
        return 1
    a = n
    tmp = n - 1
    while (tmp >= l):
        a = a * tmp % mod
        tmp -= 1
    return a


class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

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

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())


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)

    divisors.sort()
    return divisors


inf = 10 ** 18
mod = 10 ** 9 + 7

n = ir()
a = lr()
ans = []
zeroflag = False
neg = 0
for num in a:
    if num == 0:
        zeroflag = True
    if num < 0:
        neg+=1
    ans.append(abs(num))
if zeroflag:
    print(sum(ans))
else:
    ans.sort()
    if neg%2 == 0:
        print(sum(ans))
    else:
        print(sum(ans[1:])-ans[0])

Solution (Python):
def main():
    import sys

    def input(): return sys.stdin.readline().rstrip()

    n = int(input())
    a = list(map(int, input().split()))
    s, m = 0, 10**18
    flag = 1
    for x in a:
        s += abs(x)
        flag ^= (x<0)
        m = min(m, abs(x))

    if flag or (0 in a):
        print(s)
    else:
        print(s-2*m)
        
    
    
if __name__ == '__main__':
    main()

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

ans = 0
smallest = 10 ** 9 + 1
nega = 0
for i in range(len(A)):
  if A[i] < 0:
    nega ^= 1
    A[i] *= -1
  ans += A[i]
  if A[i] < smallest:
    smallest = A[i]
  
if nega:
  ans -= smallest * 2
  
print(ans)

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

if __name__ == "__main__":
    main()

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

cnt = 0
m = 0
for a in As:
  if a < 0:
    cnt += 1
    
if cnt % 2 == 0:
  print(sum(map(abs, As)))
else:
  print(sum(map(abs, As))-2*min(map(abs, As)))

Solution (Python):
import numpy as np

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

if np.count_nonzero(a < 0) % 2 == 0:
    print(np.abs(a).sum())
else:
    b = np.abs(a)
    m = b.min()
    print(b.sum() - 2 * m)

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

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

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

Solution (Python):
n = int(input())
aas = list(map(int, input().split()))
cnt = 0
res = 0
mini = float('inf')
for i in aas:
    if i < 0:
        cnt += 1
    res += abs(i)
    mini = min(mini, abs(i))
if cnt%2 == 0:
    print(res)
    exit()
print(res - mini*2)

Solution (Python):
n=int(input())
a=list(map(int,input().split()))
cnt=0
ans=0
mini=10000000000
for i in a:
    if i<0:
        cnt+=1
    p=abs(i)
    ans+=p
    if p<mini:
        mini=p
if cnt%2==1:
    ans-=mini*2
print(ans)

Solution (Python):
import sys
sys.setrecursionlimit(10 ** 9)

def int1(x): return int(x) - 1
def II(): return int(input())
def MI(): return map(int, input().split())
def MI1(): return map(int1, input().split())
def LI(): return list(map(int, input().split()))
def LI1(): return list(map(int1, input().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def MS(): return input().split()
def LS(): return list(input())
def LLS(rows_number): return [LS() for _ in range(rows_number)]
def printlist(lst, k=' '): print(k.join(list(map(str, lst))))
INF = float('inf')




import numpy as np  


def solve():
    N = II()
    A = LI()

    dp = np.zeros((N + 1, 2), np.float64)
    dp[0, 1] = -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(int(dp[N, 0]))


if __name__ == '__main__':
    solve()

Solution (Python):
import sys
sys.setrecursionlimit(10 ** 9)

def int1(x): return int(x) - 1
def II(): return int(input())
def MI(): return map(int, input().split())
def MI1(): return map(int1, input().split())
def LI(): return list(map(int, input().split()))
def LI1(): return list(map(int1, input().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def MS(): return input().split()
def LS(): return list(input())
def LLS(rows_number): return [LS() for _ in range(rows_number)]
def printlist(lst, k=' '): print(k.join(list(map(str, lst))))
INF = float('inf')







def solve():
    N = II()
    A = LI()

    minus = 0
    for a in A:
        if a < 0:
            minus += 1

    if minus % 2 == 0:
        ans = sum(map(lambda x: abs(x), A))
    else:
        ans = 0
        mn = INF
        for a in A:
            ans += abs(a)
            mn = min(mn, abs(a))
        ans -= 2 * mn

    print(ans)

if __name__ == '__main__':
    solve()

Solution (Python):
def resolve():
    N = int(input())
    A = [int(i) for i in input().split()]
    cntM = 0
    for i in range(N):
        if A[i] < 0:
            A[i] *= -1
            cntM += 1
    if 0 in A or cntM % 2 == 0:
        print(sum(A))
    else:
        print(sum(A) - min(A) * 2)

resolve()

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

cnt = 0

for a in A:
    if a > 0:
        cnt += 1
        
if (len(A)-cnt)%2==0 or 0 in A:
    print(S)
else:
    print(S-2*min(map(abs, A)))

Solution (Python):
from math import ceil,floor,comb,factorial,gcd,pow,sqrt,log2,cos,sin,tan,acos,asin,atan,degrees,radians,pi,inf
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from collections import deque,defaultdict,Counter
from bisect import bisect_left,bisect_right
from operator import itemgetter
from heapq import heapify,heappop,heappush
from queue import Queue,LifoQueue,PriorityQueue
from copy import deepcopy
from time import time
import string
import sys
sys.setrecursionlimit(10 ** 7)
def input() : return sys.stdin.readline().strip()
def INT()   : return int(input())
def MAP()   : return map(int,input().split())
def LIST()  : return list(MAP())

n = INT()
a = LIST()
dp = [[0]*n for i in range(2)]



for i in range(n):
    if i == 0:
        dp[0][i] = a[i]
        dp[1][i] = -a[i]
    else:
        dp[0][i] = max(dp[0][i-1]+a[i], dp[1][i-1]-a[i])
        dp[1][i] = max(dp[0][i-1]-a[i], dp[1][i-1]+a[i])

print(dp[0][-1])

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

cnt = sum(i < 0 for i in a)
ans = sum(abs(i) for i in a)
if cnt % 2 == 0:
    print(ans)
elif cnt % 2 == 1:
    print(ans - 2 * min(abs(i) for i in a))

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

ans = 0
c = 0
tmp_m = 10**9
zero = False
for i in range(n):
    if a[i] < 0:
        c += 1
    elif a[i] == 0:
        zero = True
    tmp = abs(a[i])
    ans += tmp
    tmp_m = min(tmp_m,tmp)

if zero:
    print(ans)
else:
    if c%2 == 0:
        print(ans)
    else:
        print(ans-tmp_m*2)

Solution (Python):
import sys

sys.setrecursionlimit(10**9)
input = sys.stdin.readline

def ii(): return int(input())
def mi(): return map(int, input().split())
def lmi(): return list(map(int, input().split()))
def lmif(n): return [list(map(int, input().split())) for _ in range(n)]
def ss(): return input().split()

def main():
    mod = 1000000007
    
    N = ii()
    A = lmi()

    mz_count = 0 
    mz_min = 10 ** 10
    ans = 0
    for i in A:
        if i <= 0:
            mz_count += 1
            i = -i
        ans += i
        if mz_min > i:
            mz_min = i
    
    if mz_count % 2 == 0:
        print(ans)
    else:
        print(ans - 2 * mz_min)    

    return

main()

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


plus_sum = 0

minus_num = 0

min_abs = 10**10

for a in A:
    plus_sum += abs(a)
    if a < 0:
        minus_num += 1
    if abs(a) < abs(min_abs):
        min_abs = a


if 0 in A:
    print(plus_sum)

else:
    
    
    if minus_num % 2 == 0:
        print(plus_sum)

    
    elif minus_num % 2 == 1:
        ans = plus_sum - 2 * abs(min_abs)
        print(ans)

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

minus = []
plus = []
for i in A:
    if (i < 0):
        minus.append(i)
    else:
        plus.append(i)

if (len(minus) % 2 == 0 or 0 in plus):
    
    print(sum(plus) - sum(minus))
    exit()


min_abs = 10**9 + 7
for i in A:
    min_abs = min(min_abs, abs(i))

sum_ans = 0
for i in A:
    sum_ans += abs(i)

print(sum_ans - min_abs * 2)

Solution (Python):

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

Solution (Python):
n = int(input())
lst = list(map(int, input().split()))
mcnt = 0
for i in range(n):
  if lst[i] < 0:
    mcnt += 1
if 0 in lst or mcnt % 2 == 0:
  print(sum(list(map(abs, lst))))
  exit()
m = min(lst, key=abs)
print(sum(list(map(abs, lst))) - 2 * abs(m))

Solution (Python):
n = int(input())
a = list(map(int,input().split()))
a_abs = [0]*n
is_minus = [0]*n

for i in range(n):
    if a[i] >= 0:
        a_abs[i] = a[i]
    else:
        a_abs[i] = -1 * a[i]
        is_minus[i] = 1

a_abs.sort()
if sum(is_minus) % 2 == 0:
    ans = sum(a_abs)
else:
    ans = sum(a_abs) - 2*a_abs[0]

print(ans)

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

mi=10**9+1
S=0
cnt=0
for i in range(N):
    if A[i]<0:
        cnt+=1
    a=abs(A[i])
    S+=a
    mi=min(mi,a)

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

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

pos = []
neg = []
ans = 0

for e in A:
    if e > 0:
        pos.append(e)
    else:
        neg.append(e)
if len(neg) % 2 == 0:
    ans = sum(abs_A)
else:
    """pos.sort(reverse=True)
    neg.sort(reverse=True)
    if len(neg) == N:
        ans = -sum(neg[:-1]) + neg[-1]
    else:"""
    
    
    ans = sum(abs_A)
    ans -= 2 * min(abs_A)
print(ans)

Solution (Python):
n=int(input())
a=list(map(int,input().split()))
tmp=float("inf")
flg=True
b=list(map(lambda x:abs(x),a))
ans=sum(b)
t=sum(b)
for i in range(n):
    if a[i]==0:
        print(ans)
        exit()
    if a[i]<0:
        if flg:
            flg=False
        else:
            flg=True
    if abs(a[i])<tmp:
        tmp=abs(a[i])
if flg:
    print(ans)
else:
    print(ans-2*tmp)

Solution (Python):
import sys
sys.setrecursionlimit(10**7)
input = sys.stdin.readline

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

cnt = 0
mi = 10**9
for i in range(n):
    if a[i] < 0 or a[i] == 0:
        cnt += 1
    mi = min(mi, abs(a[i]))

sum = 0
for i in a:
    sum += abs(i)

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

Solution (Python):
n = int(input())
alst = list(map(int, input().split()))
minus = 0
for num in alst:
    if num < 0:
        minus += 1

blst = [abs(num) for num in alst]
blst.sort()

if 0 in alst:
    print(sum(blst))
elif minus % 2 == 0:
    print(sum(blst))
else:
    print(sum(blst[1:]) - blst[0])

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

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

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

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

Alist = list(map(int, input().split()))
plus = [abs(a) for a in Alist]

cnt = 0

for a in Alist:
    if a < 0:
        cnt += 1

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

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

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

import numpy as np

neg_cnt = len(list(filter(lambda x: x<0, A)))
abs_lis = np.abs(A)
sum_abs = sum(abs_lis)
if neg_cnt % 2 ==0:
    print(sum_abs)
else:
    print(sum_abs-2*min(abs_lis))

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

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

for i in range(n-1):
  f= 1 if a[i]*f>=0 else -1
print (sm if f*a[n-1]>0  or 0 in a else sm-2*min(map(abs,a)))

Solution (Python):
import sys
n=int(input())
A=list(map(int,input().split()))
count=0
for elem in A:
    if elem < 0:
        count+=1
if count%2==0:
    for i in range(len(A)):
        A[i]=abs(A[i])
    print(sum(A))
    sys.exit()
else:
    tmp=1000000000000
    for elem in A:
        tmp=(min(tmp,abs(elem)))
    for i in range(len(A)):
        A[i]=abs(A[i])
    print(sum(A)-2*tmp)

Solution (Python):
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(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7 

from decimal import *



N = INT()
A = LIST()
a = [abs(x) for x in A] 

n = sum([A[i] != a[i] for i in range(N)]) 

if n%2:
	print(sum(a) - 2*min(a))
else:
	print(sum(a))

Solution (Python):
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(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7 

from decimal import *



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))

Solution (Python):
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(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7 

from decimal import *



N = INT()
A = LIST()
a = [abs(x) for x in A] 

n = sum([A[i] != a[i] for i in range(N)]) 

if n%2:
	print(sum(a) - 2*min(a))
else:
	print(sum(a))

Solution (Python):
N = int(input())
A = list(map(int, input().split()))
abs_A = [abs(i) for i in A]

minus = 0
for i in range(N):
    minus += A[i] < 0

if minus % 2 == 0:
    print(sum(abs_A))
else:
    mini = float('inf')
    for i in range(N):
        mini = min(mini, abs_A[i])
    print(sum(abs_A) - 2*mini)

Solution (Python):
N = int(input())
A = list(map(int,input().split()))
A_abs = []
cnt = 0
ans = 0

for a in A:
    if a < 0:
        cnt += 1
    A_abs.append(abs(a))

if A_abs.count(0) > 0:
    print(sum(A_abs))
elif cnt % 2 == 0:
    print(sum(A_abs))
else:
    print(sum(A_abs)- 2 * min(A_abs))

Solution (Python):
n, *a = map(int, open(0).read().split())
minus_cnt = len([1 for A in a if A < 0])
ans = sum([abs(A) for A in a])
if (0 not in a) and (minus_cnt %2 != 0):
    ans -= 2 * min([abs(A) for A in a])
print(ans)

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

def main(n,a):
    sump=0
    summ=0
    minm=-10**9
    minp=10**9
    countm=0
    for i in range(n):
        if a[i]>=0:
            sump+=a[i]
            minp=min(minp,a[i])
        else:
            countm+=1
            summ+=a[i]
            minm=max(minm,a[i])
    
    if countm%2==0:
        return sump-summ
    else:
        return sump-summ-min(minp,abs(minm))*2

if __name__=='__main__':
    n,a=readinput()
    ans=main(n,a)
    print(ans)

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

m = 0
ans = []
for i in a:
  if i < 0:
    m += 1
    ans.append(abs(i))
  else:
    ans.append(i)
if m % 2 == 0:
  print(sum(ans))
else:
  x = min(ans)
  print(sum(ans)-x*2)

Solution (Python):
n = int(input())
plus = []
minus = []
for a in map(int,input().split()):
    if a>=0:
        plus.append(a)
    else:
        minus.append(a)
ans = sum(plus)-sum(minus)
if len(minus)%2==1:
    if plus==[]:
        ans = ans + 2*max(minus)
    else:
        ans = ans - 2*min(abs(max(minus)),min(plus))
print(ans)

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

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

cnt = 0

for v in a:
    if v < 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):
import sys
import itertools

import time
import math
import heapq
 
sys.setrecursionlimit(10 ** 7)
 
from collections import defaultdict
 
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
INF = 10 ** 9 + 7




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

negs = 0
abs_min = INF
total = 0
for a in A:
    if a < 0:
        negs += 1
    abs_min = min(abs_min, abs(a))
    total += abs(a)

if negs % 2 == 0:
    print(total)
else:
    print(total - abs_min * 2)

Solution (Python):
import collections
N =int(input())
As = [int(item) for item in input().split()]

cnt = 0
Bs = collections.deque()
min1 = 1000000000000

for i in As:
	if i < 0:
		cnt +=1
	Bs.append(abs(i))
	min1=min(min1, abs(i))
	
if cnt % 2 ==0:
	print(sum(list(Bs)))
else:
	print(sum(list(Bs))-min1*2)

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

if cnt % 2 == 0 or cnt_0 >= 1:
    ans = sum(b)
else:
    ans = sum(b) - min(b) * 2

print(ans)

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()))
A=[]
B=[]
for i in range (n):
  p=abs(a[i])
  A.append(p)
  if a[i]<0:
    B.append(a[i])
if len(B)%2==0:
  print(sum(A))
else:
  print(sum(A)-(min(A)*2),)