import sys

sys.setrecursionlimit(1000000)



class Solution():

    def dp(self, pos, sign):

        if pos == self.n-1:

            if sign == 0:

                return +self.lst[pos]

            else:

                return -self.lst[pos]

        elif (pos, sign) in self.vis:

            return self.rcd[pos][sign]

        elif sign == 0:

            self.rcd[pos][sign] = max(self.dp(pos+1, 0) + self.lst[pos], self.dp(pos+1, 1) - self.lst[pos])

            self.vis.add((pos, sign))

            return self.rcd[pos][sign]

        else:

            self.rcd[pos][sign] = max(self.dp(pos+1, 0) - self.lst[pos], self.dp(pos+1, 1) + self.lst[pos])

            self.vis.add((pos, sign))

            return self.rcd[pos][sign]



    def run(self):

        self.n = int(eval(input()))

        self.lst = list(map(int, input().split()))

        self.rcd = [[0, 0] for _ in range(self.n)]

        self.vis = set()

        print((self.dp(0, 0)))



solution = Solution()

solution.run()

# D - Flipping Signs

# https://atcoder.jp/contests/abc125/tasks/abc125_



import sys

sys.setrecursionlimit(1000000)



N = int(eval(input()))

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



visit = dict()



def dp(pos, sign):

    # terminal condition

    if pos == N-1:

        if sign == 0:

            return A[pos]

        else:

            return -A[pos]



    if (pos, sign) in visit:

        return visit[(pos, sign)]



    elif sign == 0:

        # memorize

        visit[(pos, sign)] = max( dp(pos+1, 0) + A[pos], dp(pos+1, 1) - A[pos])

        return visit[(pos, sign)]



    else: # st == 1

        # memorize

        visit[(pos, sign)] = max( dp(pos+1, 0) -  A[pos], dp(pos + 1, 1) + A[pos])

        return visit[(pos, sign)]



print('{}'.format( dp(0,0) ))

import sys

sys.setrecursionlimit(1000000)


class Solution:
    def dp(self, pos, sign):
        if pos == self.n - 1:
            if sign == 0:
                return +self.lst[pos]
            else:
                return -self.lst[pos]
        elif (pos, sign) in self.vis:
            return self.rcd[pos][sign]
        elif sign == 0:
            self.rcd[pos][sign] = max(
                self.dp(pos + 1, 0) + self.lst[pos], self.dp(pos + 1, 1) - self.lst[pos]
            )
            self.vis.add((pos, sign))
            return self.rcd[pos][sign]
        else:
            self.rcd[pos][sign] = max(
                self.dp(pos + 1, 0) - self.lst[pos], self.dp(pos + 1, 1) + self.lst[pos]
            )
            self.vis.add((pos, sign))
            return self.rcd[pos][sign]

    def run(self):
        self.n = int(eval(input()))
        self.lst = list(map(int, input().split()))
        self.rcd = [[0, 0] for _ in range(self.n)]
        self.vis = set()
        print((self.dp(0, 0)))


solution = Solution()
solution.run()

# D - Flipping Signs
# https://atcoder.jp/contests/abc125/tasks/abc125_
import sys

sys.setrecursionlimit(1000000)
N = int(eval(input()))
A = list(map(int, input().split()))
visit = dict()


def dp(pos, sign):
    # terminal condition
    if pos == N - 1:
        if sign == 0:
            return A[pos]
        else:
            return -A[pos]
    if (pos, sign) in visit:
        return visit[(pos, sign)]
    elif sign == 0:
        # memorize
        visit[(pos, sign)] = max(dp(pos + 1, 0) + A[pos], dp(pos + 1, 1) - A[pos])
        return visit[(pos, sign)]
    else:  # st == 1
        # memorize
        visit[(pos, sign)] = max(dp(pos + 1, 0) - A[pos], dp(pos + 1, 1) + A[pos])
        return visit[(pos, sign)]


print("{}".format(dp(0, 0)))

+# D - Flipping Signs +# https://atcoder.jp/contests/abc125/tasks/abc125_ +N = int(eval(input())) +A = list(map(int, input().split())) +visit = dict() -class Solution: -    def dp(self, pos, sign): -        if pos == self.n - 1: -            if sign == 0: -                return +self.lst[pos] -            else: -                return -self.lst[pos] -        elif (pos, sign) in self.vis: -            return self.rcd[pos][sign] -        elif sign == 0: -            self.rcd[pos][sign] = max( -                self.dp(pos + 1, 0) + self.lst[pos], self.dp(pos + 1, 1) - self.lst[pos] -            ) -            self.vis.add((pos, sign)) -            return self.rcd[pos][sign] +def dp(pos, sign): +    # terminal condition +    if pos == N - 1: +        if sign == 0: +            return A[pos] -            self.rcd[pos][sign] = max( -                self.dp(pos + 1, 0) - self.lst[pos], self.dp(pos + 1, 1) + self.lst[pos] -            ) -            self.vis.add((pos, sign)) -            return self.rcd[pos][sign] - -    def run(self): -        self.n = int(eval(input())) -        self.lst = list(map(int, input().split())) -        self.rcd = [[0, 0] for _ in range(self.n)] -        self.vis = set() -        print((self.dp(0, 0))) +            return -A[pos] +    if (pos, sign) in visit: +        return visit[(pos, sign)] +    elif sign == 0: +        # memorize +        visit[(pos, sign)] = max(dp(pos + 1, 0) + A[pos], dp(pos + 1, 1) - A[pos]) +        return visit[(pos, sign)] +    else:  # st == 1 +        # memorize +        visit[(pos, sign)] = max(dp(pos + 1, 0) - A[pos], dp(pos + 1, 1) + A[pos]) +        return visit[(pos, sign)] -solution = Solution() -solution.run() +print("{}".format(dp(0, 0)))