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

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

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

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

-def solve(): +def main(): +    inf = 10**14 + 1 -    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] +    (*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) -    print((solve())) +    main()