#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
using P = pair<int,int>;
using pq = priority_queue<int>;
typedef long long ll;

int  main()
{
	int n;
	cin >> n;
	vector <long> a(n);
	rep(i, n)
		cin >> a[i];
	vector <long> b(n, 0);
	ll sum = 0;
	long max = a[0];
	int i = 0;
	while (i < n)
	{
		if (max < a[i])
			max = a[i];
		else if (a[i] < max)
			sum += max - a[i];
		i++;
	}
	cout << sum << endl;
	return (0);
}

#include <iostream>
#include <unordered_map>
#include <string>
#include <algorithm>
using namespace std;
int main(void){
    long long N;
    cin >> N;
    long long A[N];
    long long count = 0;
    long long sum=0;
    long long ans ;
    for(int i=0;i<N;i++){
        cin >> A[i];
        if(A[i] < 0)count++;
        sum += abs(A[i]);
    }
    
    if(count % 2 == 0){
        ans = sum;
    }
    else{
        ans = 0;
        for(int i=0;i<N;i++){
            ans = max(ans,sum-abs(A[i])*2);
        }
    }
    cout << ans << endl;
}
