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

abs_min = 10**10
minus_cnt = 0
for i in range(n):
    abs_min = min(abs(a[i]), abs_min)
    if a[i] < 0:
        minus_cnt += 1
        a[i] *= -1

if minus_cnt %2 == 0:
    print(sum(a))
else:
    print(sum(a) - abs_min*2)

Solution (Python):
N = int(raw_input())
A = map(long, raw_input().split())

minus_count = 0
min_abs = 10 ** 9
sum = 0
for a in A:
    if a < 0:
        minus_count += 1
    abs_a = abs(a)
    if abs_a < min_abs:
        min_abs = abs_a
    sum += abs_a

if minus_count % 2 > 0:
    sum -= 2*min_abs

print sum

Solution (Python):
n = int(input())
a = [int(i) for i in input().split()]
c = 0
d = 0
for i in range(n):
    if a[i] < 0:
        c += 1
        a[i] *= -1
    if a[i] == 0:
        d += 1

c %= 2

if d > 0:
    c = 0



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

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

Solution (Python):
n=int(input())
a=list(map(int, input().split()))
pos=[]
nega=[]

for i in range(n):
    if a[i]>=0:
        pos.append(a[i])
    else:
        nega.append(a[i])
if len(pos)==0:
    if len(nega)%2==0:
        print(abs(sum(a)))
    else:
        print(abs(sum(a))+max(a)*2)
elif len(nega)==0:
    print(sum(a))
elif len(nega)%2==0:
    print(sum(pos)-sum(nega))
else:
    if min(pos)>-max(nega):
        print(sum(pos)-sum(nega)+max(nega)*2)
    else:
        print(sum(pos)-sum(nega)-min(pos)*2)

Solution (Python):
 
N = int(input())
A = list(map(int, input().split()))
mn_count = len([0 for i in A if i < 0])
AA = [abs(i) for i in A]
mn = min(AA) if mn_count % 2 else 0

print(sum(AA) - mn*2)

Solution (Python):
import sys
def p(*a):
  s=" ".join(map(str,a))
  
  sys.stderr.write(s+"\n")



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

iCount=0
iABSMin=10**9+1

for i in range(N):
	a = A[i]
	if a<0: iCount+=1
	
	b = abs(a)
	ABS.append(b)
	
	iABSMin=min(iABSMin,b)
	
	

if iCount%2==0:
	print(sum(ABS))
	exit()


ans=sum(ABS)-(iABSMin*2)
print(ans)

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

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

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

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

m = 10 ** 9
c = 0
ans = 0

for x in a:
    m = min(abs(x), m)
    ans += abs(x)
    if x < 0:
        c += 1

if c % 2 == 1:
    ans -= m * 2

print(ans)

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

num_negative = sum(a < 0 for a in A)
A_abs = [abs(a) for a in A]

if num_negative % 2 == 0:
    result = sum(A_abs)
else:
    result = sum(A_abs) - 2 * min(A_abs)

print(result)

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



signA = sum([1 for a in A if a<0])

absA = [abs(a) for a in A]
absA.sort()

sumA = sum(absA)
      
         
if any([a==0 for a in A]):
  print(sumA)
elif signA%2==0:
  print(sumA)
elif signA%2!=0:
  print(sumA - 2*absA[0])

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

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

absmin = float('inf')
minusnum = 0
ans = 0

for i in A:
    ans += abs(i)
    if abs(i) < absmin:
        absmin = abs(i)
    if i < 0:
        minusnum += 1

if minusnum % 2 == 0:
    print(ans)
else:
    print(ans - 2*absmin)

Solution (Python):
N = int(input())
l = list(map(int,input().split()))
l.sort()
s = 0
for i in range(int(len(l)/2)):
  if l[2*i] * l[2*i+1]>0:
  	s += abs(l[2*i] + l[2*i+1])
  else:
    l1 = l[2*i] + l[2*i+1]
    l2 = - l1
    s += l1 if l1>l2 else l2
if(len(l)%2==1):
  s += l[-1]
  
print(s)

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

mini = min(B)
cnt = 0
for i in range(N):
    if A[i] < 0:
        cnt += 1

if cnt % 2 == 0:
    ans = sum(B)
else:
    ans = sum(B) - mini * 2
print(ans)

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

Solution (Python):
_ = input()
A = list(map(int, input().split()))
B = []

minus = 0

for i in A:
    if i < 0:
        minus += 1
    B.append(abs(i))

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

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

b = []
count = 0
for v in a:
    if v < 0:
        count += 1
        b.append(-v)
    else:
        b.append(v)
if count % 2 == 1:
    b = sorted(b)
    print(sum(b) - 2 * b[0])
else:
    print(sum(b))

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

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

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

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

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

Solution (Python):
import numpy as np
import fractions

if __name__ == "__main__":
    N = int(input())
    A = list(map(int, input().split()))
    dp = {}
    dp[0, 0] = 0
    dp[0, 1] = -100000000000
    for i in range(1, N):
        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(max(dp[N-1,0]+A[N-1], dp[N-1,1]-A[N-1]))

Solution (Python):
N=int(input())
s=0
m=10**9
pl=0
mi=0

arr=list(map(int,input().split(" ")))

for z in arr:
  s+=abs(z)
  if z>0:
    pl+=1
  elif z<0:
    mi+=1
  if m>abs(z):
    m=abs(z)

if mi%2==0:
  ans=s
else:
  ans=s-2*m
print(ans)

Solution (Python):
import sys



import numpy as np

from fractions import Fraction

"""Template"""


class IP:
    """
    入力を取得するクラス
    """

    def __init__(self):
        self.input = sys.stdin.readline

    def I(self):
        """
        1文字の取得に使います
        :return: int
        """
        return int(self.input())

    def S(self):
        """
        1文字の取得(str
        :return: str
        """
        return self.input()

    def IL(self):
        """
        1行を空白で区切りリストにします(int
        :return: リスト
        """
        return list(map(int, self.input().split()))

    def SL(self):
        """
        1行の文字列を空白区切りでリストにします
        :return: リスト
        """
        return list(map(str, self.input().split()))

    def ILS(self, n):
        """
        1列丸々取得します(int
        :param n: 行数
        :return: リスト
        """
        return [int(self.input()) for _ in range(n)]

    def SLS(self, n):
        """
        1列丸々取得します（str
        :param n: 行数
        :return: リスト
        """
        return [self.input() for _ in range(n)]

    def SILS(self, n):
        """
        Some Int LineS
        横に複数、縦にも複数
        :param n: 行数
        :return: list
        """
        return [self.IL() for _ in range(n)]

    def SSLS(self, n):
        """
        Some String LineS
        :param n: 行数
        :return: list
        """
        return [self.SL() for _ in range(n)]


class Idea:
    def __init__(self):
        pass

    def HF(self, p):
        """
        Half enumeration
        半分全列挙です
        pの要素の和の組み合わせを作ります。
        ソート、重複削除行います
        :param p: list : 元となるリスト
        :return: list : 組み合わせられた和のリスト
        """
        return sorted(set(p[i] + p[j] for i in range(len(p)) for j in range(i, len(p))))

    def Bfs2(self, a):
        """
        bit_full_search2
        bit全探索の改良版
        全探索させたら2進数のリストと10進数のリストを返す
        :return: list２つ : １個目 2進数(16桁)  2個目 10進数
        """
        
        
        
        value = []
        for i in range(1 << len(a)):
            output = []

            for j in range(len(a)):
                if self.bit_o(i, j):
                    """右からj+1番目のiが1かどうか判定"""
                    
                    output.append(a[j])
            value.append([format(i, 'b').zfill(16), sum(output)])

        value.sort(key=lambda x: x[1])
        bin = [value[k][0] for k in range(len(value))]
        val = [value[k][1] for k in range(len(value))]
        return bin, val

    def S(self, s, r=0, m=-1):
        """
        ソート関係行います。色々な設定あります。
        :param s: 元となるリスト
        :param r: reversするかどうか 0=False 1=True
        :param m: （2次元配列）何番目のインデックスのソートなのか
        :return: None
        """
        r = bool(r)
        if m == -1:
            s.sort(reverse=r)
        else:
            s.sort(reverse=r, key=lambda x: x[m])

    def bit_n(self, a, b):
        """
        bit探索で使います。0以上のときにTrue出します
        自然数だからn
        :param a: int
        :param b: int
        :return: bool
        """
        return bool((a >> b & 1) > 0)

    def bit_o(self, a, b):
        """
        bit探索で使います。1のときにTrue出すよ
        oneで1
        :param a: int
        :param b: int
        :return: bool
        """
        return bool(((a >> b) & 1) == 1)

    def ceil(self, x, y):
        """
        Round up
        小数点切り上げ割り算
        :param x: int
        :param y: int
        :return: int
        """
        return -(-x // y)

    def ave(self, a):
        """
        平均を求めます
        :param a: list
        :return: int
        """
        return sum(a) / len(a)

    def gcd(self, x, y):
        if y == 0:
            return x
        else:
            return self.gcd(y, x % y)


"""ここからメインコード"""


def main():
    
    r, e, p = range, enumerate, print
    ip = IP()
    id = Idea()
    mod = 10 ** 9 + 7

    """この下から書いてね"""
    n = ip.I()
    a = ip.IL()
    a_abs = np.abs(np.array(a))
    m = np.sign(a)
    o = np.where(m == -1, 1, 0)
    if sum(o) % 2 == 0:
        p(sum(a_abs))
    else:
        a_abs.sort()
        p(sum(a_abs) - (a_abs[0] * 2))



main()

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

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

x = 0
z = 0

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

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

if z ==0 and x%2 ==1:
    print(sum(b)-min(b)*2)
else:
    print(sum(b))

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

Solution (Python):
n = int(input())
a = [int(i) for i in input().split()]
b = 1
absum = 0
m = 10 ** 9
for i in range(n):
    if a[i] < 0:
        b *= (-1)
        absum += (-a[i])
        m = min(m,-a[i])
    else:
        absum += a[i]
        m = min(m,a[i])

if b == -1:
    print(absum -  2 * m)
    
    
else:
    print(absum)

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

mina = pow(10, 9) + 7
mc = 0
ans = 0
for a in alist:
  if abs(a) < mina:
    mina = abs(a)
  if a < 0:
    mc += 1
    ans += -a
  else:
    ans += a

if mc % 2 == 0:
  print(ans)
else:
  print(ans - 2 * mina)

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

Solution (Python):
def solve(aaa):
    bbb = list(map(abs, aaa))
    if 0 in aaa:
        return sum(bbb)
    if sum(1 for a in aaa if a < 0) % 2 == 0:
        return sum(bbb)
    return sum(bbb) - 2 * min(bbb)


n = int(input())
aaa = list(map(int, input().split()))
print(solve(aaa))

Solution (Python):
N = int(input())
A = list(map(int, input().split()))
s = 0
m = 10**9
n = 0
for x in A:
    if x < 0:
        n += 1
        x = -x
    s += x
    m = min(m, x)
if n%2 == 1:
    s -= 2*m
print(s)

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

Solution (Python):
import sys
stdin = sys.stdin
 
sys.setrecursionlimit(10**5) 
 
def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x)-1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

n = ni()
a = list(li())

absmin = float('inf')
minusnum = 0
ans = 0
for ai in a:
    absmin = min(absmin, abs(ai))
    
    if ai < 0:
        minusnum += 1
        
    ans += ai if ai > 0 else -ai
        
if minusnum % 2 == 0:
    print(ans)

else:
    print(ans - 2*absmin)

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

Solution (Python):
N=int(input())
A=[int(i) for i in input().split()]
def CountMinusAndZeroAndMin(lis):
    curmin=1000000000000000
    plussum=0
    minus=0
    for i in lis:
        j=abs(i)
        plussum+=j
        curmin=min(j,curmin)
        if i<0:
           minus+=1
    return(minus,plussum,curmin)
minus,plussum,minabs=CountMinusAndZeroAndMin(A)
if minabs==0 or minus%2==0:
    print(plussum)
else:
    print(plussum-2*minabs)

Solution (Python):
from sys import exit

N = int(input())
A = sorted([int(n) for n in input().split()], key=lambda x:abs(x))





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

if(minus):
    print(sum(A) - A[0]*2)
else:
    print(sum(A))

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

count_even = 0
for i in range(n//2):
    if a[i*2+1]<=0:
        count_even += 1
count_odd = 0
for i in range((n+1)//2):
    if a[i*2]<=0:
        count_odd += 1
ans = 0
for i in range(n):
    ans += abs(a[i])
if (count_even - count_odd) % 2 == 0:
    print(ans)
else:
    a_abs = [abs(a[i]) for i in range(n)]
    print(ans - min(a_abs)*2)

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

cnt = 0
flag = False

for i in range(n):
    if a[i] < 0:
        a[i] = -a[i]
        cnt += 1
    elif a[i] == 0:
        flag = True
    else:
        continue

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

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] = -1*a[i]

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

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

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

total = sum(abs_a)

if count%2==0:
	print(total)
else:
	smallest = min(abs_a)
	print(total - (2*smallest))

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

total = 0
smallest = 9999999999999999999999999999999
counter = 0
for i in range(n):
    total += abs(nums[i])
    smallest = min(smallest, abs(nums[i]))
    if nums[i] < 0:
        counter += 1

if counter % 2 == 0:
    print(total)
else:
    print(total - 2*smallest)

Solution (Python):
N=int(input())
A=[int(x) for x in input().split()]
A.sort()
B=sorted(A,key=lambda x:abs(x))
m=0
for i in range(N):
  if A[i]<0:
    m+=1
  else:
    break
ans=0
for i in range(m):
  ans-=A[i]
for i in range(m,N):
  ans+=A[i]
if m%2==1:
  ans-=abs(B[0])*2
print(ans)

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

num_negative = len(list(filter(lambda e: e < 0, a)))

a2 = [abs(e) for e in a]
if num_negative % 2 == 0:
    print(sum(a2))
else:
    print(sum(a2) - 2 * min(a2))

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):
N = int(input())
a = list(map(int, input().split()))

sa = 0
min_v = float('inf')
minus_count = 0
for aa in a:
    if aa < 0:
        minus_count += 1
        aa = abs(aa)
    min_v = min(min_v, aa)
    sa += aa

if minus_count % 2 == 0:
    print(sa)
else:
    print(sa - min_v * 2)

Solution (Python):


if __name__ == '__main__':
    N = int(input())
    numbers = list(map(int, input().split()))

    minus_count = len([n for n in numbers if n < 0])
    absolute_numbers = [abs(n) for n in numbers]

    if minus_count % 2 == 0:
        print(sum(absolute_numbers))
    else:
        min_num = min(absolute_numbers)
        print(sum(absolute_numbers)-min_num*2)

Solution (Python):
N, *A = map(int, open(0).read().split())

p = 0; q = -10**18
for a in A:
    p, q = max(p + a, q - a), max(p - a, q + a)
print(p)

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

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

minus_num = 0

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

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

Solution (Python):

N=int(input())
a=list(map(int,input().split()))
b=[0]*N
minus=0
ans=0
for i in range(N):
    if a[i]<=0:
        minus+=1
for i in range(N):
    b[i]=abs(a[i])
c=sorted(b)

if minus%2==1:
    for i in range(N-1):
        ans= ans+c[N-i-1]
    ans=ans-c[0]
else:
    for i in range(N):
        ans= ans+c[N-i-1]
print(ans)

Solution (Python):
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits

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()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

N = INT()
A = LIST()

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

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

Solution (Python):
import bisect
import numpy as np

N=int(input())

A=list(map(int,input().split()))
A.sort()
minus=bisect.bisect_left(A,0)
Aabs=np.abs(np.array(A))
if minus%2==0 or (minus!=N and A[minus]==0):
  print(np.sum(Aabs))
else:
  Aabs_sort=np.sort(Aabs)
  print(np.sum(Aabs)-(2*Aabs_sort[0]))

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


absmin = abs(A[0])
m = 0
sum = 0

for i in A:
    if i < 0:
        m += 1
    sum += abs(i)
    absmin = min(abs(i),absmin)


if m%2 == 1:
    sum -= absmin*2

print(sum)

Solution (Python):
N = int(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])

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

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

if minus % 2 == 0:
    print(sum(map(abs,A)))
else:
    b = min(map(abs,A))
    print(sum(map(abs,A))-2*b)

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

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

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

for i in range(N):
    a[i] = abs(a[i])
if minus % 2 == 0:
    print(sum(a))
else:
    print(sum(a)-2*min(a))

Solution (Python):
N = int(input())
A = [int(a) for a in input().split()]
negcnt = 0
mi = 1<<100
s = 0
for a in A:
    s += abs(a)
    mi = min(mi, abs(a))
    if a <= 0:
        negcnt += 1
if negcnt % 2:
    print(s-2*mi)
else:
    print(s)

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

cnt = 0
zero = False
for i in range(N):
    if A[i] < 0:
        cnt += 1
        A[i] *= -1
    elif A[i] == 0:
        zero = True
if cnt % 2 == 0 or zero:
        print(sum(A))
else:
    print(sum(A) - 2*min(A))

Solution (Python):
from heapq import heappush,heappop
import queue
import re
import math
import functools

def int_raw():
    return int(input())

def ss_raw():
    return input().split()

def ints_raw():
    return list(map(int, ss_raw()))

INF = 1<<29

def make1d_arr(n,val=INF):
    return [val for i in range(n)]

def make2d_arr(h,w,val =INF):
    return [[val for i in range(w)]for i in range(h)]


N = int_raw()
A = ints_raw()


def main():
    numNega = len([a for a in A if a<0])
    numZero = len([a for a in A if a==0])
    absA = list(map(abs,A))
    if numZero >1 or numNega%2 == 0:
        return sum(absA)
    else:
        minAbs = min(absA)
        return sum(absA)-minAbs*2

print(main())

Solution (Python):
from bisect import bisect_left, bisect_right
from collections import Counter, defaultdict, deque, OrderedDict
from copy import deepcopy
from fractions import gcd
from functools import lru_cache, reduce
from math import ceil, floor
from sys import setrecursionlimit

import heapq
import itertools
import operator



inf = float('inf')
N = 0
A = []


def set_inputs():
    global N, A
    N = get_int()
    A = get_li()
    return


def main():
    setrecursionlimit(100000)
    set_inputs()
    
    if 0 in A:
        print(sum(abs(a) for a in A))
    elif len(list(filter(lambda x: x < 0, A))) % 2 == 0:
        print(sum(abs(a) for a in A))
    else:
        m = min(abs(a) for a in A)
        print(sum(abs(a) for a in A) - 2 * m)
    return


def get_int():
    return int(input())


def get_float():
    return float(input())


def get_str():
    return input().strip()


def get_li():
    return [int(i) for i in input().split()]


def get_lf():
    return [float(f) for f in input().split()]


def get_lc():
    return list(input().strip())


def get_data(n, types, sep=None):
    if len(types) == 1:
        return [types[0](input()) for _ in range(n)]
    return list(zip(*(
        [t(x) for t, x in zip(types, input().split(sep=sep))]
        for _ in range(n)
    )))


if __name__ == '__main__':
    main()

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

dp = [[0, 0] for i in range(N+1)]
dp[0][1] = -10**18
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[-1][0])

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

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

min_a = 10 ** 9
negative_count = 0
ans = 0
for a in A:
    if a < 0:
        negative_count += 1
    a = abs(a)
    ans += a
    if a < min_a:
        min_a = a
if negative_count % 2 == 0:
    print(ans)
else:
    print(ans - 2 * min_a)

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

from functools import reduce

SUM = reduce(lambda x,y: abs(x) + abs(y) , A)

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

if cntMinu % 2 == 0:
    print(SUM)
    exit()

minAbs = 10**9 + 1
for a in A:
    if minAbs > abs(a): minAbs = abs(a)

print(SUM - 2 * minAbs )

Solution (Python):
N = int(input())
A = list(map(int, input().split()))
absMin = float('inf')
absSum = 0
numMinus = 0
for a in A:
  if a < 0:
    numMinus += 1
  ab = abs(a)
  absSum += ab
  absMin = absMin if absMin < ab else ab

if numMinus % 2 == 0:
  print(absSum)
else:
  print(absSum - 2 * absMin)

Solution (Python):
n = int(input())
a = [0]+list(map(int, input().split()))+[0]
INF = 1000000000000000000
F = [-INF]*(n+2)
G = [-INF]*(n+2)
F[1] = 0
for i in range(1, n):
	F[i+1] = max(F[i+1], F[i]+a[i], G[i]-a[i])
	G[i+1] = max(G[i+1], F[i]-a[i], G[i]+a[i])
print(max(F[n]+a[n], G[n]-a[n]))

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

Solution (Python):


import sys


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

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return input()


def main():
    n = II()
    A = LI()

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

    abs_A = [abs(a) for a in A]
    if minus % 2:
        return sum(abs_A) - min(abs_A) * 2
    else:
        return sum(abs_A)


print(main())

Solution (Python):

n = int(input())

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


min_ = 10**9
sum_ = 0
m_count = 0
for a in An:
    if a < 0:
        m_count += 1

    t = abs(a)
    min_ = min(min_, t)
    sum_ += t



ans = sum_ if m_count % 2 == 0 else sum_ - 2*min_

print(ans)

Solution (Python):
import sys
input=sys.stdin.readline
n=int(input())
A=list(map(int,input().split()))
B=[]
for a in A:
    B.append(abs(a))
cnt=0
for a in A:
    if a==0:
        cnt=0
    if a<0:
        cnt+=1
print(sum(B)-min(B)*2 if cnt%2 else sum(B))

Solution (Python):

from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS():return list(map(list, sys.stdin.readline().split()))
def S(): return list(sys.stdin.readline())[:-1]
def IR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = I()
    return l
def LIR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LI()
    return l
def SR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = S()
    return l
def LSR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LS()
    return l
sys.setrecursionlimit(1000000)
mod = 1000000007


def A():
    a,b,t = LI()
    k = t//a
    print(k*b)
    return


def B():
    n = I()
    v = LI()
    c = LI()
    ans = 0
    for i in range(n):
        if v[i] > c[i]:
            ans += (v[i]-c[i])
    print(ans)
    return


def C():
    def gcd(a,b):
        if a == 0:
            return b
        return gcd(b%a, a)
    n = I()
    a = LI()
    ans = 1
    for i in range(n):
        b = a[:i]+a[i+1:]
        g = b[0]
        for j in range(a):
            print()
    return


def D():
    n = I()
    a = LI()
    k = 0
    for i in a:
        if i < 0:
            k += 1
    ans = 0
    m = float("inf")
    for i in a:
        ans += abs(i)
        m = min(m,abs(i))
    if k%2:
        ans -= 2*m
    print(ans)
    return



if __name__ == "__main__":
    D()

Solution (Python):
n = int(input())
a = list(map(int,input().split()))
absa = list(map(abs,a))
in0 = True if 0 in a else False
if in0:
    ans = sum(absa)
else:
    mc = 0
    for i in a:
        if i < 0:
            mc += 1
    if mc % 2 == 0:
        ans = sum(absa)
    else:
        ans = sum(absa)-2*min(absa)
print(ans)

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

Solution (Python):
import sys

















input = sys.stdin.readline
def ii(): return int(input())
def mi(): return map(int, input().rstrip().split())
def lmi(): return list(map(int, input().rstrip().split()))
def li(): return list(input().rstrip())



N = ii()
A = lmi()
absA = list(map(abs, A))
absA.sort()
cnt = 0

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

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

Solution (Python):
n = int(input())
a = list(map(int, input().split()))
newa = [abs(a[i]) for i in range(n)]

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

res = 0 
for i in range(n):
    res += newa[i]
        
if neg%2 == 0:
    print(res)
else:
    if zeros > 0:
        print(res)
    else:
        res -= 2*min(newa)
        print(res)

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

minAbs = 10**10 

s = 0
cntminus = 0
for d in dat:
    if abs(d)<minAbs:
        minAbs = abs(d)
    if d<0:
        cntminus+=1
    s+=abs(d)
if cntminus%2:
    s-=minAbs*2

print(s)

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

if minus%2 == 0:
    print(ans)
else:
    print(ans - 2*q)

Solution (Python):
import fractions
def solve():
  n = int(input())
  a = list(int(i) for i in input().split())
  flip = 0
  for i in range(n):
    if a[i] <0:
      a[i] *= -1
      flip += 1
  if flip %2 == 0:
   print(sum(a))
  else:
   print(sum(a)-2*min(a))
solve()

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

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

C=[]
for i in range(N):
    C.append(abs(B[i]))
C.sort()
if M%2==1:
    print(sum(C)-2*C[0])
else:
    print(sum(C))