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

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

-    DP = [[-(10**20)] * 2 for _ in range(N)] -    DP[0][0] = A[0] -    DP[0][1] = -1 * A[0] +    DP = [[-(10**20), -(10**20)] for _ in range(N)]  # [-1が偶数, -1が奇数] +    DP[0] = [A[0], -1 * A[0]] -        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]) +        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)