#include <iostream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <assert.h>
#include <stdio.h>
#include <ctime>
#include <cstdlib>
#include <utility>
#include <string.h>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <map>

#define inf (999999999)
#define pii pair<int,int>
#define pip pair<int,pii>
#define pll pair<unsigned long long,unsigned long long>
#define eps 1e-8

#ifdef ONLINE_JUDGE
#define debug(args...)
#else
#define debug(args...) fprintf(stderr,args)
#endif

#define pb push_back
#define mod 1000000007
#define maxn 100100

using namespace std;

vector<int> L[100100];
int ans[100100];
int foi[100100];
long long v[100100];

int imp = 0;
long long a,b;

void dfs(int x,int liga){

	foi[x] = 1;
	int foi2 = 0;

	for(vector<int> :: iterator it = L[x].begin(); it < L[x].end(); it++) if(!foi[*it]){

		if(liga){
			if(b-v[x] == v[*it] || b-v[*it] == v[x])
				ans[x] = ans[*it] = 1;
			else assert(a-v[x] == v[*it] || a-v[*it] == v[x]);
		}
		dfs(*it,1-liga);
		foi2++;

	}

	if(foi2 == 0 && liga == 1)
		imp = 1;

}

int pai[100100];
int qnt[100100];
int find(int x){
	return pai[x] = (x==pai[x])?x:find(pai[x]);}
void merge(int a,int b){
	a = pai[a];
	b = pai[b];
	qnt[a] += qnt[b];
	pai[b] = a;
}

main(){

		int n;
		scanf("%d%I64d%I64d",&n,&a,&b);

		for(int i=0;i<n;i++)
			pai[i] = i, qnt[i] = 1;

		map<int,int> mp;

		for(int i=0;i<n;i++){
			scanf("%I64d",v+i);
			assert(mp.find(v[i]) == mp.end());
			mp[v[i]] = i;
		}

		int A = -1, B = -1;

		for(int i=0;i<n;i++){
			if(2*v[i] == a) A = i;
			if(2*v[i] == b) B = i;
			if(mp.find(a-v[i]) != mp.end()) if(2*v[i] != a){
				L[i].pb(mp[a-v[i]]); merge(i,mp[a-v[i]]);}
			if(mp.find(b-v[i]) != mp.end()) if(2*v[i] != b){
				L[i].pb(mp[b-v[i]]); merge(i,mp[b-v[i]]);}
		}

		if(A+1 && B+1){
			if(qnt[find(A)]%2 == 1){
				foi[A] = 1;
				if(find(A) != find(B) && qnt[find(B)]%2 == 1){
					foi[B] = 1; ans[B] = 1;}
			}
			else if(qnt[find(B)]%2 == 1){
				foi[B] = 1;
				ans[B] = 1;
			}
		}
		else if(A+1){
			if(qnt[find(A)]%2 == 1) foi[A] = 1;}
		else if(B+1){
			if(qnt[find(B)]%2 == 1){
				foi[B] = 1;
				ans[B] = 1;
			}
		}

		for(int i=0;i<n;i++) if(!foi[i] && L[i].size() == 1)
			dfs(i,1);

		for(int i=0;i<n;i++) if(!foi[i])
			dfs(i,1);

		if(imp)
			printf("NO\n");
		else {
			printf("YES\n");
			for(int i=0;i<n;i++)
				printf("%d ",ans[i]);
			printf("\n");
		}

}


#include <iostream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <assert.h>
#include <stdio.h>
#include <ctime>
#include <cstdlib>
#include <utility>
#include <string.h>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <map>

#define inf (999999999)
#define pii pair<int,int>
#define pip pair<int,pii>
#define pll pair<unsigned long long,unsigned long long>
#define eps 1e-8

#ifdef ONLINE_JUDGE
#define debug(args...)
#else
#define debug(args...) fprintf(stderr,args)
#endif

#define pb push_back
#define mod 1000000007
#define maxn 100100

using namespace std;

vector<int> L[100100];
int ans[100100];
int foi[100100];
long long v[100100];

int imp = 0;
long long a,b;

void dfs(int x,int liga){

	foi[x] = 1;
	int foi2 = 0;
	debug("dfs %d\n",v[x]);

	for(vector<int> :: iterator it = L[x].begin(); it < L[x].end(); it++) if(!foi[*it]){

		if(liga){
			if(b-v[x] == v[*it] || b-v[*it] == v[x])
				ans[x] = ans[*it] = 1;
			else assert(a-v[x] == v[*it] || a-v[*it] == v[x]);
		}
		dfs(*it,1-liga);
		foi2++;

	}

	if(foi2 == 0 && liga == 1)
		imp = 1;

}

int pai[100100];
int qnt[100100];
int find(int x){
	return pai[x] = (x==pai[x])?x:find(pai[x]);}
void merge(int a,int b){
	a = find(a);
	b = find(b);
	if(a == b) return;
	qnt[a] += qnt[b];
	pai[b] = a;
}

main(){

		int n;
		scanf("%d%I64d%I64d",&n,&a,&b);

		for(int i=0;i<n;i++)
			pai[i] = i, qnt[i] = 1;

		map<int,int> mp;

		for(int i=0;i<n;i++){
			scanf("%I64d",v+i);
			assert(mp.find(v[i]) == mp.end());
			mp[v[i]] = i;
		}

		int A = -1, B = -1;

		for(int i=0;i<n;i++){
			if(2*v[i] == a) A = i;
			if(2*v[i] == b) B = i;
			if(mp.find(a-v[i]) != mp.end()) if(2*v[i] != a){
				L[i].pb(mp[a-v[i]]); merge(i,mp[a-v[i]]);}
			if(mp.find(b-v[i]) != mp.end()) if(2*v[i] != b){
				L[i].pb(mp[b-v[i]]); merge(i,mp[b-v[i]]);}
		}

		debug("qnt = %d %d\n",qnt[find(A)],qnt[find(B)]);
		if(A+1 && B+1){
			if(qnt[find(A)]%2 == 1){
				foi[A] = 1;
				if(find(A) != find(B) && qnt[find(B)]%2 == 1){
					foi[B] = 1; ans[B] = 1;}
			}
			else if(qnt[find(B)]%2 == 1){
				foi[B] = 1;
				ans[B] = 1;
			}
		}
		else if(A+1){
			if(qnt[find(A)]%2 == 1) foi[A] = 1;}
		else if(B+1){
			if(qnt[find(B)]%2 == 1){
				foi[B] = 1;
				ans[B] = 1;
			}
		}

		for(int i=0;i<n;i++) if(!foi[i] && L[i].size() == 1){debug("begin %d\n",v[i]);
			dfs(i,1);}

		for(int i=0;i<n;i++) if(!foi[i])
			dfs(i,1);

		if(imp)
			printf("NO\n");
		else {
			printf("YES\n");
			for(int i=0;i<n;i++)
				printf("%d ",ans[i]);
			printf("\n");
		}

}


#include<bits/stdc++.h>
using namespace std;
main() {

    int n, x, y;
    scanf("%d%d%d", &n, &x, &y);
    set<int> s, A, B;
    vector<int> a(n);

    for( int i = 0; i < n; i++ ) {
        scanf("%d", &a[i]);
        s.insert(a[i]);
    }

    for( int val : a ) {
        int k = 0;
        if( s.find(x-val) != s.end() ) k++;
        if( s.find(y-val) != s.end() ) k++;
        if( !k ) {
            printf("NO");
            return 0;
        }
        if( k == 2 ) continue;
        if( s.find(x-val) != s.end() ) A.insert(val);
            else B.insert(val);
    }

    for( int i = 0; i < n; i++ ) {
        if( A.find(a[i]) != A.end() ) continue;
        if( B.find(a[i]) != B.end() ) continue;
        printf("NO");
        return 0;
    }

    printf("YES\n");
    for( int val : a )
        if( A.find(val) != A.end() ) printf("0 ");
        else printf("1 ");

    return 0;
}


#include<bits/stdc++.h>
using namespace std;
main() {
    #ifndef ONLINE_JUDGE
    freopen("1.txt", "r", stdin);
    #endif // ONLINE_JUDGE

    int n, x, y;
    scanf("%d%d%d", &n, &x, &y);
    int a[n];
    for( int i = 0; i < n; i++ )
        scanf("%d", &a[i]);

    multiset<int> A, B, tmp;
    for( int i = 0; i < n; i++ )
        if( tmp.find(x-a[i]) != tmp.end() ) {
            A.insert(a[i]);
            A.insert(x-a[i]);
            tmp.erase(tmp.find(x-a[i]));
        } else tmp.insert(a[i]);

    while(!tmp.empty()) {
        int val = *tmp.begin();
        tmp.erase(val);
        if( tmp.find(y-val) != tmp.end() ) {
            B.insert(val);
            B.insert(y-val);
            tmp.erase(tmp.find(y-val));
            continue;
        }
        if( A.find(y-val) == A.end() ) {
            printf("NO");
            return 0;
        }
        B.insert(val);
        B.insert(y-val);
        A.erase(A.find(y-val));
    }

    for( int val : A )
        if( A.find(x-val) == A.end() ) {
            printf("NO");
            return 0;
        }

    for( int i = 0; i < n; i++ )
        if( A.find(a[i]) != A.end() ) {
            printf("0 ");
            A.erase(A.find(a[i]));
        } else {
            printf("1 ");
            B.erase(B.find(a[i]));
        }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;

bool f( vector<int> a, int y ) {
    set<int> s;
    for( int val : a )
        s.insert(val);
    for( int val : a )
        if( s.find(y-val) == s.end() ) return false;
    printf("YES\n");
    for( int i = 0; i < a.size(); i++)
        printf("1 ");
    return true;
}

main() {
    #ifndef ONLINE_JUDGE
    freopen("1.txt", "r", stdin);
    #endif // ONLINE_JUDGE

    int n, x, y;
    scanf("%d%d%d", &n, &x, &y);
    vector<int> a(n);
    for( int i = 0; i < n; i++ )
        scanf("%d", &a[i]);

    if( f(a, y) ) return 0;

    multiset<int> A, B, tmp;
    for( int i = 0; i < n; i++ )
        if( tmp.find(x-a[i]) != tmp.end() ) {
            A.insert(a[i]);
            A.insert(x-a[i]);
            tmp.erase(tmp.find(x-a[i]));
        } else tmp.insert(a[i]);

    while(!tmp.empty()) {
        int val = *tmp.begin();
        tmp.erase(val);
        B.insert(val);
        if( B.find(y-val) != B.end() ) continue;
        if( tmp.find(y-val) != tmp.end() ) {
            B.insert(y-val);
            tmp.erase(tmp.find(y-val));
            continue;
        }
        if( A.find(y-val) == A.end() ) {
            printf("NO");
            return 0;
        }
        B.insert(y-val);
        A.erase(A.find(y-val));
    }

    for( int val : A )
        if( A.find(x-val) == A.end() ) {
            printf("NO");
            return 0;
        }

    printf("YES\n");
    for( int i = 0; i < n; i++ )
        if( A.find(a[i]) != A.end() ) {
            printf("0 ");
            A.erase(A.find(a[i]));
        } else {
            printf("1 ");
            B.erase(B.find(a[i]));
        }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
main() {
    #ifndef ONLINE_JUDGE
    freopen("1.txt", "r", stdin);
    #endif // ONLINE_JUDGE

    int n, x, y;
    scanf("%d%d%d", &n, &x, &y);
    int a[n];
    for( int i = 0; i < n; i++ )
        scanf("%d", &a[i]);

    multiset<int> A, B, tmp;
    for( int i = 0; i < n; i++ )
        if( tmp.find(x-a[i]) != tmp.end() ) {
            A.insert(a[i]);
            A.insert(x-a[i]);
            tmp.erase(tmp.find(x-a[i]));
        } else tmp.insert(a[i]);

    while(!tmp.empty()) {
        int val = *tmp.begin();
        tmp.erase(val);
        if( tmp.find(y-val) != tmp.end() ) {
            B.insert(val);
            B.insert(y-val);
            tmp.erase(tmp.find(y-val));
            continue;
        }
        if( A.find(y-val) == A.end() ) {
            printf("NO");
            return 0;
        }
        B.insert(val);
        B.insert(y-val);
        A.erase(A.find(y-val));
    }

    for( int val : A )
        if( A.find(x-val) == A.end() ) {
            printf("NO");
            return 0;
        }

    printf("YES\n");
    for( int i = 0; i < n; i++ )
        if( A.find(a[i]) != A.end() ) {
            printf("0 ");
            A.erase(A.find(a[i]));
        } else {
            printf("1 ");
            B.erase(B.find(a[i]));
        }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
unordered_map<int, int> id;
int n;
vector<int> a, p;

int find_set( int v ) {
    return p[v] == v ? v : p[v] = find_set(p[v]);
}

void union_sets( int a, int b ) {
    a = find_set(a);
    b = find_set(b);
    if( rand()&1 )
        swap(a, b);
    p[a] = b;
}

void add_edge( int x, int y ) {
    if( id.find(y) == id.end() ) return;
    x = id[x];
    y = id[y];
    union_sets(x, y);
}

main() {
    #ifndef ONLINE_JUDGE
    freopen("1.txt", "r", stdin);
    #endif // ONLINE_JUDGE

    int x, y;
    scanf("%d%d%d", &n, &x, &y);
    a.resize(n);
    for( int i = 0; i < n; i++ ) {
        scanf("%d", &a[i]);
        p.push_back(i);
        id[ a[i] ] = i;
    }

    for( int i = 0; i < n; i++ ) {
        add_edge( a[i], x-a[i] );
        add_edge( a[i], y-a[i] );
    }

    vector<int> v[n], col(n);
    for( int i = 0; i < n; i++ )
        v[find_set(a[i])].push_back(a[i]);

    /*for( int i = 0; i < n; i++ ) {
        for( int x : v[i] )
            printf("%d ", x);
        printf("\n");
    }
    return 0;*/

    unordered_set<int> A;
    for( int i = 0; i < n; i++ ) {
        char ok = true;
        for( int val : v[i] )
            if( id.find(x-val) == id.end() ) ok = false;
        if( ok ) {
            for( int val : v[i] )
                A.insert(val);
            continue;
        }
        ok = true;
        for( int val : v[i] )
            if( id.find(y-val) == id.end() ) ok = false;
        if( ok ) continue;
        printf("NO");
        return 0;
    }

    printf("YES\n");
    for( int val : a )
        printf("%d ", A.find(val) == A.end());

    return 0;
}


#include<bits/stdc++.h>
using namespace std;
main() {
    #ifndef ONLINE_JUDGE
    freopen("1.txt", "r", stdin);
    #endif // ONLINE_JUDGE

    int n, x, y;
    scanf("%d%d%d", &n, &x, &y);
    int a[n];
    for( int i = 0; i < n; i++ )
        scanf("%d", &a[i]);

    multiset<int> A, B, tmp;
    for( int i = 0; i < n; i++ )
        if( tmp.find(x-a[i]) != tmp.end() ) {
            A.insert(a[i]);
            A.insert(x-a[i]);
            tmp.erase(tmp.find(x-a[i]));
        } else tmp.insert(a[i]);

    while(!tmp.empty()) {
        int val = *tmp.begin();
        tmp.erase(val);
        B.insert(val);
        if( B.find(y-val) != B.end() ) continue;
        if( tmp.find(y-val) != tmp.end() ) {
            B.insert(y-val);
            tmp.erase(tmp.find(y-val));
            continue;
        }
        if( A.find(y-val) == A.end() ) {
            printf("NO");
            return 0;
        }
        B.insert(y-val);
        A.erase(A.find(y-val));
    }

    for( int val : A )
        if( A.find(x-val) == A.end() ) {
            printf("NO");
            return 0;
        }

    printf("YES\n");
    for( int i = 0; i < n; i++ )
        if( A.find(a[i]) != A.end() ) {
            printf("0 ");
            A.erase(A.find(a[i]));
        } else {
            printf("1 ");
            B.erase(B.find(a[i]));
        }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
unordered_map<int, int> id;
int n;
vector<int> a, p;

int find_set( int v ) {
    return p[v] == v ? v : p[v] = find_set(p[v]);
}

void union_sets( int a, int b ) {
    a = find_set(a);
    b = find_set(b);
    if( rand()&1 )
        swap(a, b);
    p[a] = b;
}

void add_edge( int x, int y ) {
    if( id.find(y) == id.end() ) return;
    x = id[x];
    y = id[y];
    union_sets(x, y);
}

main() {
    #ifndef ONLINE_JUDGE
    freopen("1.txt", "r", stdin);
    #endif // ONLINE_JUDGE

    int x, y;
    scanf("%d%d%d", &n, &x, &y);
    a.resize(n);
    for( int i = 0; i < n; i++ ) {
        scanf("%d", &a[i]);
        p.push_back(i);
        id[ a[i] ] = i;
    }

    for( int i = 0; i < n; i++ ) {
        add_edge( a[i], x-a[i] );
        add_edge( a[i], y-a[i] );
    }

    vector<int> v[n], col(n);
    for( int i = 0; i < n; i++ )
        v[find_set(id[a[i]])].push_back(a[i]);

    /*for( int i = 0; i < n; i++ ) {
        for( int x : v[i] )
            printf("%d ", x);
        printf("\n");
    }
    return 0;*/

    unordered_set<int> A;
    for( int i = 0; i < n; i++ ) {
        char ok = true;
        for( int val : v[i] )
            if( id.find(x-val) == id.end() ) ok = false;
        if( ok ) {
            for( int val : v[i] )
                A.insert(val);
            continue;
        }
        ok = true;
        for( int val : v[i] )
            if( id.find(y-val) == id.end() ) ok = false;
        if( ok ) continue;
        printf("NO");
        return 0;
    }

    printf("YES\n");
    for( int val : a )
        printf("%d ", A.find(val) == A.end());

    return 0;
}


#include<bits/stdc++.h>
using namespace std;
main() {
    #ifndef ONLINE_JUDGE
    freopen("1.txt", "r", stdin);
    #endif // ONLINE_JUDGE

    int n, x, y;
    scanf("%d%d%d", &n, &x, &y);
    int a[n];
    set<int> s, A;

    for( int i = 0; i < n; i++ ) {
        scanf("%d", &a[i]);
        s.insert(a[i]);
    }

    for( int i = 0; i < n; i++ ) {
        if( s.find(x-a[i]) != s.end() && s.find(y-a[i]) != s.end() ) continue;
        if( s.find(x-a[i]) == s.end() && s.find(y-a[i]) == s.end() ) {
            printf("NO");
            return 0;
        }
        if( s.find(x-a[i]) != s.end() ) A.insert(a[i]);
    }

    printf("YES\n");
    for( int i = 0; i < n; i++ )
        printf("%d ", A.find(a[i]) == A.end());

    return 0;
}


#include <bits/stdc++.h>

using namespace std;

int a[100010];
int col[100010];
map<int, int> idx;
int flag;
int n, A, B;

int dfs(int u, int fa) {
	if (col[u]) return col[u];
	int c0 = idx[A - a[u]];
	int c1 = idx[B - a[u]];
	int x = -1, y = -1;
	if (c0 != fa) x = dfs(c0, u);
	if (c1 != fa) y = dfs(c1, u);
	assert(x != -1 || y != -1);
	if (x == -1) x = y;
	if (y == -1) y = x;
	if (x != y) flag = 1;
	return col[u] = x;
}

int main()
{
	ios::sync_with_stdio(false);
	cin >> n >> A >> B;
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
		idx[a[i]] = i;
	}
	flag = 0;
	for (int i = 1; i <= n; i++) {
		if (col[i]) continue;
		int c0 = (A - a[i] == a[i]) ? 0 : idx[A - a[i]];
		int c1 = (B - a[i] == a[i]) ? 0 : idx[B - a[i]];
		if (A == B) c1 = 0;
		if (!c0 && !c1) {
			flag = 1;
			break;
		}
		if (c0 && !c1) {
			col[i] = col[c0] = 1;
		}
		if (!c0 && c1) {
			col[i] = col[c0] = 2;
		}
	}
	if (flag) {
		puts("NO");
		return 0;
	}

	for (int i = 1; i <= n; i++) {
		if (col[i]) continue;
		dfs(i, 0);
	}

	if (flag) {
		puts("NO");
		return 0;
	}
	puts("YES");
	for (int i = 1; i <= n; i++) {
		if (i > 1) printf(" ");
		printf("%d", col[i] - 1);
	}
	puts("");
	return 0;
}


#include <bits/stdc++.h>

using namespace std;

int a[100010];
int col[100010];
map<int, int> idx;
int flag;
int n, A, B;

int dfs(int u, int fa) {
	if (col[u]) return col[u];
	int c0 = idx[A - a[u]];
	int c1 = idx[B - a[u]];
	int x = -1, y = -1;
	if (c0 != fa) x = dfs(c0, u);
	if (c1 != fa) y = dfs(c1, u);
	if (x != -1 || y != -1) while(1);
	if (x == -1) x = y;
	if (y == -1) y = x;
	if (x != y) flag = 1;
	return col[u] = x;
}

int main()
{
	ios::sync_with_stdio(false);
	cin >> n >> A >> B;
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
		idx[a[i]] = i;
	}
	flag = 0;
	for (int i = 1; i <= n; i++) {
		if (col[i]) continue;
		int c0 = (A - a[i] == a[i]) ? 0 : idx[A - a[i]];
		int c1 = (B - a[i] == a[i]) ? 0 : idx[B - a[i]];
		if (A == B) c1 = 0;
		if (!c0 && !c1) {
			flag = 1;
			break;
		}
		if (c0 && !c1) {
			col[i] = col[c0] = 1;
		}
		if (!c0 && c1) {
			col[i] = col[c0] = 2;
		}
	}
	if (flag) {
		puts("NO");
		return 0;
	}

	for (int i = 1; i <= n; i++) {
		if (col[i]) continue;
		dfs(i, 0);
	}

	if (flag) {
		puts("NO");
		return 0;
	}
	puts("YES");
	for (int i = 1; i <= n; i++) {
		if (i > 1) printf(" ");
		printf("%d", col[i] - 1);
	}
	puts("");
	return 0;
}


#include <bits/stdc++.h>

using namespace std;

int a[100010];
int col[100010];
map<int, int> idx;
int flag;
int n, A, B;

int dfs(int u, int fa) {
	if (col[u]) return col[u];
	int c0 = idx[A - a[u]];
	int c1 = idx[B - a[u]];
	int x = -1, y = -1;
	if (c0 != fa) x = dfs(c0, u);
	if (c1 != fa) y = dfs(c1, u);
	assert(x != -1 || y != -1);
	if (x = -1) x = y;
	if (y = -1) y = x;
	if (x != y) flag = 1;
	return col[u] = x;
}

int main()
{
	ios::sync_with_stdio(false);
	cin >> n >> A >> B;
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
		idx[a[i]] = i;
	}
	flag = 0;
	for (int i = 1; i <= n; i++) {
		if (col[i]) continue;
		int c0 = idx[A - a[i]];
		int c1 = idx[B - a[i]];
		if (!c0 && !c1) {
			flag = 1;
			break;
		}
		if (c0 && !c1) {
			col[i] = col[c0] = 1;
		}
		if (!c0 && c1) {
			col[i] = col[c0] = 2;
		}
	}
	if (flag) {
		puts("NO");
		return 0;
	}

	for (int i = 1; i <= n; i++) {
		if (col[i]) continue;
		dfs(i, 0);
	}

	if (flag) {
		puts("NO");
		return 0;
	}
	puts("YES");
	for (int i = 1; i <= n; i++) {
		if (i > 1) printf(" ");
		printf("%d", col[i] - 1);
	}
	puts("");
	return 0;
}


#include <bits/stdc++.h>

using namespace std;

int a[100010];
int col[100010];
map<int, int> idx;
int flag;
int n, A, B;

int dfs(int u, int fa) {
	if (col[u]) return col[u];
	int c0 = idx[A - a[u]];
	int c1 = idx[B - a[u]];
	int x = -1, y = -1;
	if (c0 != fa) x = dfs(c0, u);
	if (c1 != fa) y = dfs(c1, u);
	assert(x != -1 || y != -1);
	if (x = -1) x = y;
	if (y = -1) y = x;
	if (x != y) flag = 1;
	return col[u] = x;
}

int main()
{
	ios::sync_with_stdio(false);
	cin >> n >> A >> B;
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
		idx[a[i]] = i;
	}
	flag = 0;
	for (int i = 1; i <= n; i++) {
		if (col[i]) continue;
		int c0 = (A - a[i] == a[i]) ? 0 : idx[A - a[i]];
		int c1 = (B - a[i] == a[i]) ? 0 : idx[B - a[i]];
		if (!c0 && !c1) {
			flag = 1;
			break;
		}
		if (c0 && !c1) {
			col[i] = col[c0] = 1;
		}
		if (!c0 && c1) {
			col[i] = col[c0] = 2;
		}
	}
	if (flag) {
		puts("NO");
		return 0;
	}

	for (int i = 1; i <= n; i++) {
		if (col[i]) continue;
		dfs(i, 0);
	}

	if (flag) {
		puts("NO");
		return 0;
	}
	puts("YES");
	for (int i = 1; i <= n; i++) {
		if (i > 1) printf(" ");
		printf("%d", col[i] - 1);
	}
	puts("");
	return 0;
}


#include <bits/stdc++.h>

using namespace std;

int a[100010];
int col[100010];
map<int, int> idx;
int flag;
int n, A, B;

int dfs(int u, int fa) {
    if (col[u]) return col[u];
    int c0 = idx[A - a[u]];
    int c1 = idx[B - a[u]];
    int x = -1, y = -1;
    if (c0 != fa) x = dfs(c0, u);
    if (c1 != fa) y = dfs(c1, u);
    assert(x != -1 || y != -1);
    if (x = -1) x = y;
    if (y = -1) y = x;
    if (x != y) flag = 1;
    return col[u] = x;
}

int main()
{
    ios::sync_with_stdio(false);
    cin >> n >> A >> B;
    for (int i = 1; i <= n; i++) {
        cin >> a[i];
        idx[a[i]] = i;
    }
    flag = 0;
    for (int i = 1; i <= n; i++) {
        if (col[i]) continue;
        int c0 = (A - a[i] == a[i]) ? 0 : idx[A - a[i]];
        int c1 = (B - a[i] == a[i]) ? 0 : idx[B - a[i]];
        if (A == B) c1 = 0;
        if (!c0 && !c1) {
            flag = 1;
            break;
        }
        if (c0 && !c1) {
            col[i] = col[c0] = 1;
        }
        if (!c0 && c1) {
            col[i] = col[c0] = 2;
        }
    }
    if (flag) {
        puts("NO");
        return 0;
    }

    for (int i = 1; i <= n; i++) {
        if (col[i]) continue;
        dfs(i, 0);
    }

    if (flag) {
        puts("NO");
        return 0;
    }
    puts("YES");
    for (int i = 1; i <= n; i++) {
        if (i > 1) printf(" ");
        printf("%d", col[i] - 1);
    }
    puts("");
    return 0;
}


#include<bits/stdc++.h>
#define mk make_pair
#define pk push_back
using namespace std;
typedef long long LL;
typedef pair<int,int> pi;
template<class T> bool cmax(T &x,T y){return y>x?x=y,1:0;}
template<class T> bool cmin(T &x,T y){return y<x?x=y,1:0;}
const int N=2e5+5;
int n,a[N];
LL f[N][3][2][2];
int main(){
	ios::sync_with_stdio(false);
	cin>>n;
	for(int i=1;i<=n;++i) cin>>a[i];
	if(n==1){
		cout<<a[1]<<endl;
		return 0;
	}
	memset(f,-0x3f,sizeof f);
	f[1][2][0][0]=-a[1];
	f[1][1][1][0]=a[1];
	for(int i=1;i<n;++i)
		for(int j=0;j<3;++j)
			for(int k=0;k<2;++k)
				for(int t=0;t<2;++t)
					cmax(f[i+1][(j+2)%3][0][t|(k==0)],f[i][j][k][t]-a[i+1]),
					cmax(f[i+1][(j+1)%3][1][t|(k==1)],f[i][j][k][t]+a[i+1]);
	cout<<max(f[n][1][0][1],f[n][1][1][1])<<endl;
	return 0;
}


#include<bits/stdc++.h> //Ithea Myse Valgulious
namespace chtholly{
typedef long long ll;
#define re0 register int
#define rel register ll
#define rec register char
#define gc getchar
//#define gc() (p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<23,stdin),p1==p2)?-1:*p1++)
#define pc putchar
#define p32 pc(' ')
#define pl puts("")
/*By Citrus*/
char buf[1<<23],*p1=buf,*p2=buf;
inline int read(){
  int x=0,f=1;char c=gc();
  for (;!isdigit(c);c=gc()) f^=c=='-';
  for (;isdigit(c);c=gc()) x=(x<<3)+(x<<1)+(c^'0');
  return f?x:-x;
  }
template <typename mitsuha>
inline bool read(mitsuha &x){
  x=0;int f=1;char c=gc();
  for (;!isdigit(c)&&~c;c=gc()) f^=c=='-';
  if (!~c) return 0;
  for (;isdigit(c);c=gc()) x=(x<<3)+(x<<1)+(c^'0');
  return x=f?x:-x,1;
  }
template <typename mitsuha>
inline int write(mitsuha x){
  if (!x) return 0&pc(48);
  if (x<0) pc('-'),x=-x;
  int bit[20],i,p=0;
  for (;x;x/=10) bit[++p]=x%10;
  for (i=p;i;--i) pc(bit[i]+48);
  return 0;
  }
inline char fuhao(){
  char c=gc();
  for (;isspace(c);c=gc());
  return c;
  }
}using namespace chtholly;
using namespace std;
const int yuzu=2e5;
typedef ll fuko[yuzu|10];
struct node{ll a,id;}p[yuzu|10];
int main() {
  int i,n=read();
  ll s=0,tmp=0;
  for (i=1;i<=n;++i) p[i]={read(),i},s+=p[i].a;
  if (n==1) return printf("%lld\n",s)&0;
  sort(p+1,p+n+1,[&](node a,node b){return a.a<b.a;});
  auto ck=[&](int x) {
    for (int i=1;i<=x;++i)
      if (p[i].id&1) return tmp;
    return tmp-p[x].a+p[x+1].a;
  };
  ll zw=9e9;
  for (i=0;i<=n;++i) {
    tmp+=p[i].a;
    if (i%3==(4-n%3)%3)
      zw=min(zw,n&1&&n/2==i?ck(i):tmp);
  }
  printf("%lld\n",s-2*zw);
}


//Code By CXY07
#include<bits/stdc++.h>
using namespace std;

//#define FILE
#define int long long
//#define ull unsigned long long
#define LL long long
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define fst first
#define scd second
#define inv(x) qpow((x),mod - 2)
#define lowbit(x) ((x) & (-(x)))

const int MAXN = 2e5 + 10;
const int INF = 2e9;
const double PI = acos(-1);
const double eps = 1e-6;
//const int mod = 1e9 + 7;
//const int mod = 998244353;
//const int G = 3;
//const int base = 131;

int n,m;
int s[MAXN];
int dp[MAXN][3][2][2];

template<typename T> inline void read(T &a) {
	a = 0; char c = getchar(); int f = 1;
	while(c < '0' || c > '9') {if(c == '-') f = -1; c = getchar();}
	while(c >= '0' && c <= '9') {a = a * 10 + (c ^ 48); c = getchar();}
	a *= f;
}

signed main () {
#ifdef FILE
	freopen(".in","r",stdin);
	freopen(".out","w",stdout);
#endif
	read(n);
	for(int i = 1;i <= n; ++i) read(s[i]);
	memset(dp,-0x3f,sizeof dp);
	if(n == 1) return printf("%lld\n",s[1]),0;
	dp[1][1][0][0] = s[1];
	dp[1][2][0][0] = -s[1];
	for(int i = 1;i < n; ++i) {
		for(int m = 0;m <= 2; ++m) {
			for(int a = 0;a <= 1; ++a)
				for(int b = 0;b <= 1; ++b)
					dp[i + 1][(m + 1) % 3][1][a | (b == 1)] = max(dp[i + 1][(m + 1) % 3][1][a | (b == 1)],dp[i][m][b][a] + s[i + 1]),
					dp[i + 1][(m + 2) % 3][0][a | (b == 0)] = max(dp[i + 1][(m + 2) % 3][0][a | (b == 0)],dp[i][m][b][a] - s[i + 1]);
		}
	}
	printf("%lld\n",max(dp[n][1][0][1],dp[n][1][1][1]));
	return 0;
}


//Code By CXY07
#include<bits/stdc++.h>
using namespace std;

//#define FILE
#define int long long
//#define ull unsigned long long
#define LL long long
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define fst first
#define scd second
#define inv(x) qpow((x),mod - 2)
#define lowbit(x) ((x) & (-(x)))

const int MAXN = 2e5 + 10;
const int INF = 2e9;
const double PI = acos(-1);
const double eps = 1e-6;
//const int mod = 1e9 + 7;
//const int mod = 998244353;
//const int G = 3;
//const int base = 131;

int n,m;
int s[MAXN];
int dp[MAXN][3][2][2];

template<typename T> inline void read(T &a) {
	a = 0; char c = getchar(); int f = 1;
	while(c < '0' || c > '9') {if(c == '-') f = -1; c = getchar();}
	while(c >= '0' && c <= '9') {a = a * 10 + (c ^ 48); c = getchar();}
	a *= f;
}

signed main () {
#ifdef FILE
	freopen(".in","r",stdin);
	freopen(".out","w",stdout);
#endif
	read(n);
	for(int i = 1;i <= n; ++i) read(s[i]);
	memset(dp,-0x3f,sizeof dp);
	if(n == 1) return printf("%lld\n",s[1]),0;
	dp[1][1][1][0] = s[1];
	dp[1][2][0][0] = -s[1];
	for(int i = 1;i < n; ++i) {
		for(int m = 0;m <= 2; ++m) {
			for(int a = 0;a <= 1; ++a)
				for(int b = 0;b <= 1; ++b)
					dp[i + 1][(m + 1) % 3][1][b || (a == 1)] = max(dp[i + 1][(m + 1) % 3][1][b || (a == 1)],dp[i][m][a][b] + s[i + 1]),
					dp[i + 1][(m + 2) % 3][0][b || (a == 0)] = max(dp[i + 1][(m + 2) % 3][0][b || (a == 0)],dp[i][m][a][b] - s[i + 1]);
		}
	}
	printf("%lld\n",max(dp[n][1][0][1],dp[n][1][1][1]));
	return 0;
}


#include<bits/stdc++.h>
#define int long long
using namespace std;
void pr(int x,bool fl=false)  {  cout<<x<<endl;  if(fl) exit(0); }
void pr(int x,int y,bool fl=false)  {  cout<<x<<" "<<y<<endl;  if(fl) exit(0); }
#define F(i,a,b) for(int i=a;i<=b;i++)
#define For(i,a,b,k) for(int i=a;i<=b;i+=k)
#define rof(i,b,a) for(int i=b;i>=a;i--)
#define roF(i,b,a) for(int i=b;i>=a;i-=k)
#define quick_pow qpow

const int mod=998244353;
//const int mod=1000000007;//1e9+7
//const int inf=LLONG_MAX;
//const int inf=INT_MAX;
const int inf=LLONG_MAX/3-1;
//const int inf=INT_MAX/3-1;
const int minf=LLONG_MIN;
//const int minf=INT_MIN;
//const int minf=LLONG_MIN/3+1;
//const int minf=INT_MIN/3+1;
const int maxn=200000;
//const int maxn=1000;
//const int maxn=2000000;
const int maxc=26;
//const int maxc=36;
//const int maxc=128;

void chkmax(int &_max,int x) {_max=max(_max,x);}
void chkmin(int &_min,int x) {_min=min(_min,x);}
void modadd(int &now,int x,int p=mod) {while(now<0) now+=p;x%=p;now%=p;now+=x;now%=p;while(now<0) now+=p;}
void modmul(int &now,int x,int p=mod) {while(now<0) now+=p;x%=p;now%=p;now*=x;now%=p;while(now<0) now+=p;}
//bool cmp(int a,int b) {return a>b;}
//bool cmp(node a,node b) {return a.val>b.val;}
int qpow(int a, int b,int p=mod) {int ans=1;a%=p;while(b){if(b&1) ans*=a;a*=a;ans%=p;a%=p;b/=2;}return ans;}
int inv(int a,int p=mod) {return quick_pow(a%p, p-2, p);}
#define FES(rt) for(int i=0;i<e[rt].size();i++)
#define gnxt nxt=e[rt][i]
#define mkp make_pair
#define pb push_back
#define fastio ios::sync_with_stdio(false)
#define P pair<int,int>
#define PR(x,n) cout<<x[i]<<(i==n?'\n':' ')
int c,xx,y,z,n,m,q,k,l,r,u,v,w,tmp,nxt,rt,cur,dis;
int ans,val,flag,cnt;
int a[maxn+5],b[maxn+5],x[maxn+5];
int dp[maxn+5][3][2];//1-(+-+-+-+),0-not
/*--------------------------------------------------*/

/*--------------------------------------------------*/

signed main()
{
fastio;
int test_case=1;
//cin>>test_case;
while(test_case--){
cin>>n;
F(i,1,n) cin>>a[i];
if(n==1) return cout<<a[1]<<endl,0;
F(i,0,n) F(j,0,2)F(k,0,1) dp[i][j][k]=-inf;
dp[0][0][1]=0;
F(i,1,n)
{
	// +
	dp[i][0][0]=max(dp[i][0][0],dp[i-1][2][0]+a[i]);
	dp[i][1][0]=max(dp[i][1][0],dp[i-1][0][0]+a[i]);
	dp[i][2][0]=max(dp[i][2][0],dp[i-1][1][0]+a[i]);
	if(i%2==0)
	{
		dp[i][0][0]=max(dp[i-1][2][1]+a[i],dp[i][0][0]);
		dp[i][1][0]=max(dp[i-1][0][1]+a[i],dp[i][1][0]);
		dp[i][2][0]=max(dp[i-1][1][1]+a[i],dp[i][2][0]);
	}
	else
	{
		dp[i][0][1]=max(dp[i][0][1],dp[i-1][2][1]+a[i]);
		dp[i][1][1]=max(dp[i][1][1],dp[i-1][0][1]+a[i]);
		dp[i][2][1]=max(dp[i][2][1],dp[i-1][1][1]+a[i]);
	}
    // -
	dp[i][0][0]=max(dp[i][0][0],dp[i-1][0][0]-a[i]);
	dp[i][1][0]=max(dp[i][1][0],dp[i-1][1][0]-a[i]);
	dp[i][2][0]=max(dp[i][2][0],dp[i-1][2][0]-a[i]);
	if(i%2==1)
	{
		dp[i][0][0]=max(dp[i][0][0],dp[i-1][0][1]-a[i]);
		dp[i][1][0]=max(dp[i][1][0],dp[i-1][1][1]-a[i]);
		dp[i][2][0]=max(dp[i][2][0],dp[i-1][2][1]-a[i]);
	}
	else
	{
		dp[i][0][1]=max(dp[i][0][1],dp[i-1][0][1]-a[i]);
		dp[i][1][1]=max(dp[i][1][1],dp[i-1][1][1]-a[i]);
		dp[i][2][1]=max(dp[i][2][1],dp[i-1][2][1]-a[i]);
	}

}
cout<<dp[n][2-n%3][0]<<endl;
}
}
/*2*/


#include<bits/stdc++.h>
#define int long long
using namespace std;
void pr(int x,bool fl=false)  {  cout<<x<<endl;  if(fl) exit(0); }
void pr(int x,int y,bool fl=false)  {  cout<<x<<" "<<y<<endl;  if(fl) exit(0); }
#define F(i,a,b) for(int i=a;i<=b;i++)
#define For(i,a,b,k) for(int i=a;i<=b;i+=k)
#define rof(i,b,a) for(int i=b;i>=a;i--)
#define roF(i,b,a) for(int i=b;i>=a;i-=k)
#define quick_pow qpow

const int mod=998244353;
//const int mod=1000000007;//1e9+7
//const int inf=LLONG_MAX;
//const int inf=INT_MAX;
const int inf=LLONG_MAX/3-1;
//const int inf=INT_MAX/3-1;
const int minf=LLONG_MIN;
//const int minf=INT_MIN;
//const int minf=LLONG_MIN/3+1;
//const int minf=INT_MIN/3+1;
const int maxn=200000;
//const int maxn=1000;
//const int maxn=2000000;
const int maxc=26;
//const int maxc=36;
//const int maxc=128;

void chkmax(int &_max,int x) {_max=max(_max,x);}
void chkmin(int &_min,int x) {_min=min(_min,x);}
void modadd(int &now,int x,int p=mod) {while(now<0) now+=p;x%=p;now%=p;now+=x;now%=p;while(now<0) now+=p;}
void modmul(int &now,int x,int p=mod) {while(now<0) now+=p;x%=p;now%=p;now*=x;now%=p;while(now<0) now+=p;}
//bool cmp(int a,int b) {return a>b;}
//bool cmp(node a,node b) {return a.val>b.val;}
int qpow(int a, int b,int p=mod) {int ans=1;a%=p;while(b){if(b&1) ans*=a;a*=a;ans%=p;a%=p;b/=2;}return ans;}
int inv(int a,int p=mod) {return quick_pow(a%p, p-2, p);}
#define FES(rt) for(int i=0;i<e[rt].size();i++)
#define gnxt nxt=e[rt][i]
#define mkp make_pair
#define pb push_back
#define fastio ios::sync_with_stdio(false)
#define P pair<int,int>
#define PR(x,n) cout<<x[i]<<(i==n?'\n':' ')
int c,xx,y,z,n,m,q,k,l,r,u,v,w,tmp,nxt,rt,cur,dis;
int ans,val,flag,cnt;
int a[maxn+5],b[maxn+5],x[maxn+5];
int dp[maxn+5][3][2];//1-(+-+-+-+),0-not
/*--------------------------------------------------*/

/*--------------------------------------------------*/

signed main()
{
fastio;
int test_case=1;
//cin>>test_case;
while(test_case--){
cin>>n;
F(i,1,n) cin>>a[i];
if(n==1) return cout<<a[1]<<endl,0;
F(i,0,n) F(j,0,2)F(k,0,1) dp[i][j][k]=-inf;
dp[0][0][1]=0;
F(i,1,n)
{
	// +
	dp[i][0][0]=max(dp[i][0][0],dp[i-1][2][0]+a[i]);
	dp[i][1][0]=max(dp[i][1][0],dp[i-1][0][0]+a[i]);
	dp[i][2][0]=max(dp[i][2][0],dp[i-1][1][0]+a[i]);
	if(i%2==0)
	{
		dp[i][0][0]=max(dp[i-1][2][1]+a[i],dp[i][0][0]);
		dp[i][1][0]=max(dp[i-1][0][1]+a[i],dp[i][1][0]);
		dp[i][2][0]=max(dp[i-1][1][1]+a[i],dp[i][2][0]);
	}
	else
	{
		dp[i][0][1]=max(dp[i][0][1],dp[i-1][2][1]+a[i]);
		dp[i][1][1]=max(dp[i][1][1],dp[i-1][0][1]+a[i]);
		dp[i][2][1]=max(dp[i][2][1],dp[i-1][1][1]+a[i]);
	}
    // -
	dp[i][0][0]=max(dp[i][0][0],dp[i-1][0][0]-a[i]);
	dp[i][1][0]=max(dp[i][1][0],dp[i-1][1][0]-a[i]);
	dp[i][2][0]=max(dp[i][2][0],dp[i-1][2][0]-a[i]);
	if(i%2==1)
	{
		dp[i][0][0]=max(dp[i][0][0],dp[i-1][0][1]-a[i]);
		dp[i][1][0]=max(dp[i][1][0],dp[i-1][1][1]-a[i]);
		dp[i][2][0]=max(dp[i][2][0],dp[i-1][2][1]-a[i]);
	}
	else
	{
		dp[i][0][1]=max(dp[i][0][1],dp[i-1][0][1]-a[i]);
		dp[i][1][1]=max(dp[i][1][1],dp[i-1][1][1]-a[i]);
		dp[i][2][1]=max(dp[i][2][1],dp[i-1][2][1]-a[i]);
	}

}
cout<<dp[n][2-n%3][0]<<endl;
}
}


#include <bits/stdc++.h>
using namespace std;
#define int long long

int32_t main(){
    ios::sync_with_stdio(0),cin.tie(0);
    int n;
    cin >> n;
    int a[n],x=0,y=0,sum=0,ans=-1e18;
    for(int i=0;i<n;i++){
        cin >> a[i];
        sum+=a[i];
        if(i%2)x+=a[i];
        else y+=a[i];
    }
    sort(a,a+n);
    if(n%3==1)ans=sum;
    for(int i=0;i<n;i++){
        sum-=2*a[i];
        if((n+i)%3==0){
            if(sum==x-y or sum==y-x)
                ans=max(ans,sum+2*(a[i]-a[i+1]));
            else ans=max(ans,sum);
        }
    }
    cout << ans;
}


#include<bits/stdc++.h>
using namespace std ;
#define Next( i, x ) for( register int i = head[x]; i; i = e[i].next )
#define rep( i, s, t ) for( register int i = (s); i <= (t); ++ i )
#define drep( i, s, t ) for( register int i = (t); i >= (s); -- i )
#define re register
#define int long long
int gi() {
	char cc = getchar() ; int cn = 0, flus = 1 ;
	while( cc < '0' || cc > '9' ) {  if( cc == '-' ) flus = - flus ; cc = getchar() ; }
	while( cc >= '0' && cc <= '9' )  cn = cn * 10 + cc - '0', cc = getchar() ;
	return cn * flus ;
}
const int N = 2e5 + 5 ;
int n, a[N], dp[N][4][2][2] ;
void cx(int &x, int y) { x = max(x, y) ; }
signed main()
{
	n = gi() ;
	rep( i, 1, n ) a[i] = gi() ;
	memset( dp, -63, sizeof(dp) ) ;
	dp[1][1][1][0] = a[1] ;
	dp[1][2][0][0] = -a[1] ;
	rep( i, 2, n ) {
		rep( j, 0, 2 ) rep( k, 0, 1 ) rep( l, 0, 1 ) {
			cx( dp[i][(j + 1) % 3][1][l | (k == 1)], dp[i - 1][j][k][l] + a[i] ) ;
			cx( dp[i][(j + 2) % 3][0][l | (k == 0)], dp[i - 1][j][k][l] - a[i] ) ;
		}
	}
	cout << max( dp[n][1][0][1], dp[n][1][1][1] ) << endl ;
	return 0 ;
}


#include<bits/stdc++.h>
using namespace std ;
#define Next( i, x ) for( register int i = head[x]; i; i = e[i].next )
#define rep( i, s, t ) for( register int i = (s); i <= (t); ++ i )
#define drep( i, s, t ) for( register int i = (t); i >= (s); -- i )
#define re register
#define int long long
int gi() {
	char cc = getchar() ; int cn = 0, flus = 1 ;
	while( cc < '0' || cc > '9' ) {  if( cc == '-' ) flus = - flus ; cc = getchar() ; }
	while( cc >= '0' && cc <= '9' )  cn = cn * 10 + cc - '0', cc = getchar() ;
	return cn * flus ;
}
const int N = 2e5 + 5 ;
int n, a[N], dp[N][4][2][2] ;
void cx(int &x, int y) { x = max(x, y) ; }
signed main()
{
	n = gi() ;
	rep( i, 1, n ) a[i] = gi() ;
	if( n == 1 ) { cout << a[1] << endl ; exit(0) ; }
	memset( dp, -63, sizeof(dp) ) ;
	dp[1][1][1][0] = a[1] ;
	dp[1][2][0][0] = -a[1] ;
	rep( i, 2, n ) {
		rep( j, 0, 2 ) rep( k, 0, 1 ) rep( l, 0, 1 ) {
			cx( dp[i][(j + 1) % 3][1][l | (k == 1)], dp[i - 1][j][k][l] + a[i] ) ;
			cx( dp[i][(j + 2) % 3][0][l | (k == 0)], dp[i - 1][j][k][l] - a[i] ) ;
		}
	}
	cout << max( dp[n][1][0][1], dp[n][1][1][1] ) << endl ;
	return 0 ;
}


#include<bits/stdc++.h>
using namespace std ;
#define Next( i, x ) for( register int i = head[x]; i; i = e[i].next )
#define rep( i, s, t ) for( register int i = (s); i <= (t); ++ i )
#define drep( i, s, t ) for( register int i = (t); i >= (s); -- i )
#define re register
int gi() {
	char cc = getchar() ; int cn = 0, flus = 1 ;
	while( cc < '0' || cc > '9' ) {  if( cc == '-' ) flus = - flus ; cc = getchar() ; }
	while( cc >= '0' && cc <= '9' )  cn = cn * 10 + cc - '0', cc = getchar() ;
	return cn * flus ;
}
const int N = 2e5 + 5 ;
int n, a[N], dp[N][4][2][2] ;
void cx(int &x, int y) { x = max(x, y) ; }
signed main()
{
	n = gi() ;
	rep( i, 1, n ) a[i] = gi() ;
	memset( dp, -63, sizeof(dp) ) ;
	dp[1][1][1][0] = a[1] ;
	dp[1][2][0][0] = -a[1] ;
	rep( i, 2, n ) {
		rep( j, 0, 2 ) rep( k, 0, 1 ) rep( l, 0, 1 ) {
			cx( dp[i][(j + 1) % 3][1][l | (k == 1)], dp[i - 1][j][k][l] + a[i] ) ;
			cx( dp[i][(j + 2) % 3][0][l | (k == 0)], dp[i - 1][j][k][l] - a[i] ) ;
		}
	}
	cout << max( dp[n][1][0][1], dp[n][1][1][1] ) << endl ;
	return 0 ;
}


#include <bits/stdc++.h>

#define rep(i,a,n) for (int i=a;i<=n;i++)
#define per(i,a,n) for (int i=n;i>=a;i--)
#define pii pair<int,int>
#define vi vector<int>
#define vii vector<vi >
#define vpii vector<pii >
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define sz(x) ((int)(x).size())
#define mod(x) ((x)%MOD)
#define o(X) (1<<(X))
#define oL(X) (1LL<<(X))
#define LL long long
#define ppt(x) ((int)__builtin_popcount(x))
using namespace std;
const int INF=0x3f3f3f3f,N=2e6+5,MOD=19260817;
const LL INF_LL=0x3f3f3f3f3f3f3f3fLL;

template <typename T>
inline int getplc(T x,int y) { return (x>>y)&1; }
template <typename T>
T square(T x) {return x*x;}

LL qpow(LL a,LL b=MOD-2,LL _MOD=MOD){
  LL res=1;
  for(;b;b>>=1,a=a*a%_MOD){
    if(b&1)
      res=res*a%_MOD;
  }
  return res;
}

template <typename T>
T Smax(T x) { return x; }
template<typename T, typename... Args>
T Smax(T a, Args... args) {
  return max(a, Smax(args...));
}
template <typename T>
T Smin(T x) { return x; }
template<typename T, typename... Args>
T Smin(T a, Args... args) {
  return min(a, Smin(args...));
}

template <typename T>
#define errorl(args...) {  \
  string _s = #args;   \
  replace(_s.begin(), _s.end(), ',', ' ');  \
  stringstream _ss(_s);  \
  istream_iterator<string> _it(_ss);  \
  errl(_it, args);  \
}
void errl(istream_iterator<string> it) {}
template<typename T, typename... Args>
void errl(istream_iterator<string> it, T a, Args... args) {
  cerr << *it << " = " << a << endl;
  errl(++it, args...);
}
#define error(args...) {  \
  string _s = #args;  \
  replace(_s.begin(), _s.end(), ',', ' ');  \
  stringstream _ss(_s);  \
  istream_iterator<string> _it(_ss);  \
  err(_it, args);  \
  cerr<<endl; \
}
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
  cerr << *it << "=" << a << " # ";
  err(++it, args...);
}

LL f[(int)2e5+5][3][2][2];

void Max(LL &x,LL y){
  x=max(x,y);
}

void Solve(){
  memset(f,-0x3f,sizeof f);
  int n;
  cin>>n;

  f[0][0][0][0]=f[0][0][0][1]=0;
  for(int i=1;i<=n;i++){
    int x;
    cin>>x;
    for(int j=0;j<3;j++){
      for(int k=0;k<2;k++){
        for(int p=0;p<2;p++){
          Max(f[i][j][i==1?0:(k|(1==p))][1],f[i-1][j][k][p]+x);
          Max(f[i][(j+1)%3][i==1?0:(k|(0==p))][0],f[i-1][j][k][p]-x);
        }
      }
      /* for(int k=0;k<2;k++){ */
      /*   for(int p=0;p<2;p++){ */
      /*     error(i,j,k,p,f[i][j][k][p]); */
      /*   } */
      /* } */
    }
  }
  LL ans=max(f[n][(3+1-n%3)%3][1][0],f[n][(3+1-n%3)%3][1][1]);
  cout<<ans<<endl;
}

int main() {
#ifndef ONLINE_JUDGE
  freopen("in.txt","r",stdin);
  /* freopen("o1.txt","w",stdout); */
#endif
  ios::sync_with_stdio(false);cin.tie(0),cout.tie(0);
  Solve();
  return 0;
}


#include <bits/stdc++.h>

#define rep(i,a,n) for (int i=a;i<=n;i++)
#define per(i,a,n) for (int i=n;i>=a;i--)
#define pii pair<int,int>
#define vi vector<int>
#define vii vector<vi >
#define vpii vector<pii >
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define sz(x) ((int)(x).size())
#define mod(x) ((x)%MOD)
#define o(X) (1<<(X))
#define oL(X) (1LL<<(X))
#define LL long long
#define ppt(x) ((int)__builtin_popcount(x))
using namespace std;
const int INF=0x3f3f3f3f,N=2e6+5,MOD=19260817;
const LL INF_LL=0x3f3f3f3f3f3f3f3fLL;

template <typename T>
inline int getplc(T x,int y) { return (x>>y)&1; }
template <typename T>
T square(T x) {return x*x;}

LL qpow(LL a,LL b=MOD-2,LL _MOD=MOD){
  LL res=1;
  for(;b;b>>=1,a=a*a%_MOD){
    if(b&1)
      res=res*a%_MOD;
  }
  return res;
}

template <typename T>
T Smax(T x) { return x; }
template<typename T, typename... Args>
T Smax(T a, Args... args) {
  return max(a, Smax(args...));
}
template <typename T>
T Smin(T x) { return x; }
template<typename T, typename... Args>
T Smin(T a, Args... args) {
  return min(a, Smin(args...));
}

template <typename T>
#define errorl(args...) {  \
  string _s = #args;   \
  replace(_s.begin(), _s.end(), ',', ' ');  \
  stringstream _ss(_s);  \
  istream_iterator<string> _it(_ss);  \
  errl(_it, args);  \
}
void errl(istream_iterator<string> it) {}
template<typename T, typename... Args>
void errl(istream_iterator<string> it, T a, Args... args) {
  cerr << *it << " = " << a << endl;
  errl(++it, args...);
}
#define error(args...) {  \
  string _s = #args;  \
  replace(_s.begin(), _s.end(), ',', ' ');  \
  stringstream _ss(_s);  \
  istream_iterator<string> _it(_ss);  \
  err(_it, args);  \
  cerr<<endl; \
}
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
  cerr << *it << "=" << a << " # ";
  err(++it, args...);
}

LL f[(int)2e5+5][3][2][2];

void Max(LL &x,LL y){
  x=max(x,y);
}

void Solve(){
  memset(f,-0x3f,sizeof f);
  int n;
  cin>>n;

  if(n==1){
    int x;cin>>x;
    cout<<x<<endl;
    return ;
  }

  f[0][0][0][0]=f[0][0][0][1]=0;
  for(int i=1;i<=n;i++){
    int x;
    cin>>x;
    for(int j=0;j<3;j++){
      for(int k=0;k<2;k++){
        for(int p=0;p<2;p++){
          Max(f[i][j][i==1?0:(k|(1==p))][1],f[i-1][j][k][p]+x);
          Max(f[i][(j+1)%3][i==1?0:(k|(0==p))][0],f[i-1][j][k][p]-x);
        }
      }
      /* for(int k=0;k<2;k++){ */
      /*   for(int p=0;p<2;p++){ */
      /*     error(i,j,k,p,f[i][j][k][p]); */
      /*   } */
      /* } */
    }
  }
  LL ans=max(f[n][(3+1-n%3)%3][1][0],f[n][(3+1-n%3)%3][1][1]);
  cout<<ans<<endl;
}

int main() {
#ifndef ONLINE_JUDGE
  freopen("in.txt","r",stdin);
  /* freopen("o1.txt","w",stdout); */
#endif
  ios::sync_with_stdio(false);cin.tie(0),cout.tie(0);
  Solve();
  return 0;
}


#ifdef _MSC_VER
#define _CRT_SECURE_NO_WARNINGS
#endif //_MSC_VER

#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <numeric>
#include <cassert>
#include <stdlib.h>
#include <ctime>
#include <functional>
#include <stack>
#include <bitset>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <cstdlib>
#include <cmath>
#include <iterator>
#include <array>
#include <random>
#include <list>
#include <forward_list>
#include <cstdint>
#include <iostream>
#include <iomanip>
#include <chrono>
#if __cplusplus >= 201703L
#include <string_view>
#endif

using ll = long long;
using pii = std::pair<int, int>;
using vi = std::vector<int>;
using vii = std::vector<pii>;
using std::cout;
using std::cin;
using std::string;
using std::vector;
using std::sort;
//using std::reverse;
//using std::less;
//using std::greater;

#define fi first
#define se second
#define sz(c)  ((int)(std::size(c)))
#define all(c) std::begin(c), std::end(c)
#define forn(i,n)  for (int i = 0, nnnn = (n); i < nnnn; ++i)
#define pb  push_back
#define doUnique(c)   (c).erase( ::std::unique( all(c) ), (c).end() )

static constexpr int DX[4] = { 1, 0, -1, 0 };
static constexpr int DY[4] = { 0, 1, 0, -1 };

//static constexpr int inf = 0x3f3f3f3f;
static constexpr int MOD = 1000000007;//998244853;//
static int powm(int x, int n) {
	int r = 1;
	while (n) {
		if (n & 1) r = (r * 1LL * x) % MOD;
		x = (x * 1LL * x) % MOD;
		n /= 2;
	}
	return r;
}
static int inv(int x) { return powm(x, MOD - 2); }
static void chmax(int& x, int y) { x = std::max(x, y); }
static void chmax(ll&x, ll y) { x = std::max(x, y); }
static constexpr int N = 1 << 18;
const ll inf = (ll)1e18;
void solve()
{
	int n;
	//cin >> n;
	scanf("%d", &n);
	ll dp[3][2] = { {0, -inf}, {-inf,-inf}, {-inf, -inf} };

	ll value;
	for (int i = 0; i < n; ++i)
	{
		//cin >> value;
		scanf("%lld", &value);
		ll dd[3][2] = { {-inf, -inf}, {-inf, -inf}, {-inf, -inf} };

		for (int j = 0; j < 3; ++j)
		{
			for (int k = 0; k < 2; ++k)
			{
				int p;
				p = k;
				if ((j + 1) % 3 == 2)p = 1;
				chmax(dd[(j + 1) % 3][p], dp[j][k] + value);
				p = k;
				if ((j + 2) % 3 == 2)p = 1;
				chmax(dd[(j + 2) % 3][p], dp[j][k] - value);
			}
		}

		memcpy(dp, dd, sizeof(dp));
	}

	if (n == 1)dp[1][1] = value;
	printf("%lld\n", dp[1][1]);
	//cout << dp[ 1 ][ 1 ] << '\n';
}

int main(int argc, char* argv[])
{

#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif //ONLINE_JUDGE
	::std::ios::sync_with_stdio(false);
	::std::cin.tie(0);
	::std::cout.tie(0);

	int tc = 1;
	//std::cin >> tc;
	for (int i= 1; i <= tc; ++i)
	{
		solve();
	}
	return 0;
}


#ifdef _MSC_VER
#define _CRT_SECURE_NO_WARNINGS
#endif //_MSC_VER

#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <numeric>
#include <cassert>
#include <stdlib.h>
#include <ctime>
#include <functional>
#include <stack>
#include <bitset>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <cstdlib>
#include <cmath>
#include <iterator>
#include <array>
#include <random>
#include <list>
#include <forward_list>
#include <cstdint>
#include <iostream>
#include <iomanip>
#include <chrono>
#include <string_view>

using ll = long long;
using pii = std::pair<int, int>;
using vi = std::vector<int>;
using vii = std::vector<pii>;
using std::cout;
using std::cin;
using std::string;
using std::vector;
using std::sort;
//using std::reverse;
//using std::less;
//using std::greater;

#define fi first
#define se second
#define sz(c)  ((int)(std::size(c)))
#define all(c) std::begin(c), std::end(c)
#define forn(i,n)  for (int i = 0, nnnn = (n); i < nnnn; ++i)
#define pb  push_back
#define doUnique(c)   (c).erase( ::std::unique( all(c) ), (c).end() )

static constexpr int DX[4] = { 1, 0, -1, 0 };
static constexpr int DY[4] = { 0, 1, 0, -1 };

//static constexpr int inf = 0x3f3f3f3f;
static constexpr int MOD = 1000000007;//998244853;//
static int powm(int x, int n) {
	int r = 1;
	while (n) {
		if (n & 1) r = (r * 1LL * x) % MOD;
		x = (x * 1LL * x) % MOD;
		n /= 2;
	}
	return r;
}
static int inv(int x) { return powm(x, MOD - 2); }
static void chmax(int& x, int y) { x = std::max(x, y); }
static void chmax(ll&x, ll y) { x = std::max(x, y); }
static constexpr int N = 1 << 18;
const ll inf = (ll)1e18;
void solve()
{
	int n;
	//cin >> n;
	scanf("%d", &n);
	ll dp[3][2] = { {0, -inf}, {-inf,-inf}, {-inf, -inf} };

	ll value;
	for (int i = 0; i < n; ++i)
	{
		//cin >> value;
		scanf("%lld", &value);
		ll dd[3][2] = { {-inf, -inf}, {-inf, -inf}, {-inf, -inf} };

		for (int j = 0; j < 3; ++j)
		{
			for (int k = 0; k < 2; ++k)
			{
				int p;
				p = k;
				if ((j + 1) % 3 == 2)p = 1;
				chmax(dd[(j + 1) % 3][p], dp[j][k] + value);
				p = k;
				if ((j + 2) % 3 == 2)p = 1;
				chmax(dd[(j + 2) % 3][p], dp[j][k] - value);
			}
		}

		memcpy(dp, dd, sizeof(dp));
	}

	if (n == 1)dp[1][1] = value;
	printf("%lld\n", dp[1][1]);
	//cout << dp[ 1 ][ 1 ] << '\n';
}

int main(int argc, char* argv[])
{

#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif //ONLINE_JUDGE
	::std::ios::sync_with_stdio(false);
	::std::cin.tie(0);
	::std::cout.tie(0);

	int tc = 1;
	//std::cin >> tc;
	for (int i= 1; i <= tc; ++i)
	{
		solve();
	}
	return 0;
}


#include <bits/stdc++.h>

using namespace std;

int main(){

    int n;
    long long ans = -1e18;

    vector<pair<int,int>> v;

    cin >> n;

    vector<int> sgn(n,1);

    long long sum = 0;
    for(int i = 1;i <= n;i++){
        v.push_back({0,i - 1});
        cin >> v.back().first;
        sum += v.back().first;
    }

    sort(v.begin(),v.end());

    int lst = 1;

    for(int i = ((1 - n) % 3 + 3) % 3;i <= n;i += 3){
        while(lst <= i){
            sum -= 2 * v[lst - 1].first;
            sgn[v[lst - 1].second] *= -1;
            lst++;
        }
        if(abs(n - 2 * i) == 1){
            bool ok = false;
            for(int i = 0;i < (int)v.size() - 1;i++){
                ok |= (sgn[i] == sgn[i + 1]);
            }
            if(ok){
                ans = max(ans,sum);
            }
            else{
                ans = max(ans,sum + 2 * v[i].first - 2 * v[i + 1].first);
            }
        }
        else{
            ans = max(ans,sum);
        }
    }

    cout << ans << "\n";

    return 0;
}


#include <bits/stdc++.h>

using namespace std;

int main(){

    int n;
    long long ans = -1e18;

    vector<pair<int,int>> v;

    cin >> n;

    vector<int> sgn(n,1);

    long long sum = 0;
    for(int i = 1;i <= n;i++){
        v.push_back({0,i - 1});
        cin >> v.back().first;
        sum += v.back().first;
    }

    sort(v.begin(),v.end());

    int lst = 1;

    for(int i = ((1 - n) % 3 + 3) % 3;i <= n;i += 3){
        while(lst <= i){
            sum -= 2 * v[lst - 1].first;
            sgn[v[lst - 1].second] *= -1;
            lst++;
        }
        if(abs(n - 2 * i) == 1){
            bool ok = false;
            for(int i = 0;i < (int)v.size() - 1;i++){
                ok |= (sgn[i] == sgn[i + 1]);
            }
            if(ok){
                ans = max(ans,sum);
            }
            else{
                ans = max(ans,sum + 2 * v[i - 1].first - 2 * v[i].first);
            }
        }
        else{
            ans = max(ans,sum);
        }
    }

    cout << ans << "\n";

    return 0;
}


#include <bits/stdc++.h>

using namespace std;

int main(){

    int n;
    long long ans = -1e18;

    vector<pair<int,int>> v;

    cin >> n;

    vector<int> sgn(n,1);

    long long sum = 0;
    for(int i = 1;i <= n;i++){
        v.push_back({0,i - 1});
        cin >> v.back().first;
        sum += v.back().first;
    }

    if(n == 1){
        cout << v.back().first << "\n";
        return 0;
    }

    sort(v.begin(),v.end());

    int lst = 1;

    for(int i = ((1 - n) % 3 + 3) % 3;i <= n;i += 3){
        while(lst <= i){
            sum -= 2 * v[lst - 1].first;
            sgn[v[lst - 1].second] *= -1;
            lst++;
        }
        if(abs(n - 2 * i) == 1){
            bool ok = false;
            for(int i = 0;i < (int)v.size() - 1;i++){
                ok |= (sgn[i] == sgn[i + 1]);
            }
            if(ok){
                ans = max(ans,sum);
            }
            else{
                ans = max(ans,sum + 2 * v[i - 1].first - 2 * v[i].first);
            }
        }
        else{
            ans = max(ans,sum);
        }
    }

    cout << ans << "\n";

    return 0;
}


#include <bits/stdc++.h>

using namespace std;

int main(){

    int n;
    long long ans = -1e18;

    vector<pair<int,int>> v;

    cin >> n;

    vector<int> sgn(n,1);

    long long sum = 0;
    for(int i = 1;i <= n;i++){
        v.push_back({0,i - 1});
        cin >> v.back().first;
        sum += v.back().first;
    }

    if(n == 1){
        cout << v.back().first << "\n";
        return;
    }

    sort(v.begin(),v.end());

    int lst = 1;

    for(int i = ((1 - n) % 3 + 3) % 3;i <= n;i += 3){
        while(lst <= i){
            sum -= 2 * v[lst - 1].first;
            sgn[v[lst - 1].second] *= -1;
            lst++;
        }
        if(abs(n - 2 * i) == 1){
            bool ok = false;
            for(int i = 0;i < (int)v.size() - 1;i++){
                ok |= (sgn[i] == sgn[i + 1]);
            }
            if(ok){
                ans = max(ans,sum);
            }
            else{
                ans = max(ans,sum + 2 * v[i - 1].first - 2 * v[i].first);
            }
        }
        else{
            ans = max(ans,sum);
        }
    }

    cout << ans << "\n";

    return 0;
}


//
/*
By:Luckyblock
*/
#include <algorithm>
#include <cctype>
#include <cstdio>
#include <cstring>
#include <vector>
#define LL long long
const LL kInf = 1e15 + 2077;
const int kN = 2e5 + 10;
//=============================================================
int n, a[kN];
LL ans = -kInf;
std::vector <LL> now;
//=============================================================
inline int read() {
  int f = 1, w = 0;
  char ch = getchar();
  for (; !isdigit(ch); ch = getchar())
    if (ch == '-') f = -1;
  for (; isdigit(ch); ch = getchar()) w = (w << 3) + (w << 1) + (ch ^ '0');
  return f * w;
}
void Chkmax(LL &fir, LL sec) {
  if (sec > fir) fir = sec;
}
void Dfs(int lth_) {
  if (lth_ == n) {
    Chkmax(ans, now[0]);
    return ;
  }
  for (int i = 0; i < n - lth_; ++ i) {
    LL tmp1 = now[i], tmp2 = now[i + 1];
    now.erase(now.begin() + i);
    now.erase(now.begin() + i);
    now.insert(now.begin() + i, - tmp1 - tmp2);
    Dfs(lth_ + 1);
    now.erase(now.begin() + i);
    now.insert(now.begin() + i, tmp2);
    now.insert(now.begin() + i, tmp1);
  }
}
//=============================================================
int main() {
  n = read();
  for (int i = 1; i <= n; ++ i) {
    a[i] = read();
    now.push_back(1ll * a[i]);
  }
  Dfs(1);
  printf("%lld\n", ans);
  return 0;
}
/*
5
1 -1 1 1 -1
*/


//
/*
By:Luckyblock
*/
#include <algorithm>
#include <cctype>
#include <cstdio>
#include <cstring>
#include <vector>
#define LL long long
const int kInf = 1e9 + 2077;
const int kN = 2e5 + 10;
//=============================================================
int n, ans = -kInf, a[kN];
std::vector <int> now;
//=============================================================
inline int read() {
  int f = 1, w = 0;
  char ch = getchar();
  for (; !isdigit(ch); ch = getchar())
    if (ch == '-') f = -1;
  for (; isdigit(ch); ch = getchar()) w = (w << 3) + (w << 1) + (ch ^ '0');
  return f * w;
}
void Chkmax(int &fir, int sec) {
  if (sec > fir) fir = sec;
}
void Dfs(int lth_) {
  if (lth_ == n) {
    Chkmax(ans, now[0]);
    return ;
  }
  for (int i = 0; i < n - lth_; ++ i) {
    int tmp1 = now[i], tmp2 = now[i + 1];
    now.erase(now.begin() + i);
    now.erase(now.begin() + i);
    now.insert(now.begin() + i, - tmp1 - tmp2);
    Dfs(lth_ + 1);
    now.erase(now.begin() + i);
    now.insert(now.begin() + i, tmp2);
    now.insert(now.begin() + i, tmp1);
  }
}
//=============================================================
int main() {
  n = read();
  for (int i = 1; i <= n; ++ i) {
    a[i] = read();
    now.push_back(a[i]);
  }
  Dfs(1);
  printf("%d\n", ans);
  return 0;
}
/*
5
1 -1 1 1 -1
*/


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
inline int read(){
	register int res=0;
	register char c=getchar(),f=1;
	while(c<48||c>57){if(c=='-')f=0;c=getchar();}
	while(c>=48&&c<=57)res=(res<<3)+(res<<1)+(c&15),c=getchar();
	return f?res:-res;
}
inline void write(int x){
	register char c[21],len=0;
	if(!x)return putchar('0'),void();
	if(x<0)x=-x,putchar('-');
	while(x)c[++len]=x%10,x/=10;
	while(len)putchar(c[len--]+48);
}
#define space(x) write(x),putchar(' ')
#define enter(x) write(x),putchar('\n')

const int N=2e5+10;
int n,a[N],f[N][3][2];
inline int cmx(int& a,int b){a=a>b?a:b;}
int main(){
	n=read();
	for(int i=1;i<=n;++i)a[i]=read();
	memset(f,192,sizeof(f));
	f[0][0][1]=0;
	for(int i=0;i<n;++i)
		for(int j=0;j<3;++j){
			cmx(f[i+1][(j+2)%3][0],f[i][j][0]-a[i+1]);
			cmx(f[i+1][(j+1)%3][0],f[i][j][0]+a[i+1]);
			cmx(f[i+1][(j+2)%3][i&1],f[i][j][1]-a[i+1]);
			cmx(f[i+1][(j+1)%3][i&1^1],f[i][j][1]+a[i+1]);
		}
	enter(f[n][1][0]);
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
inline int read(){
	register int res=0;
	register char c=getchar(),f=1;
	while(c<48||c>57){if(c=='-')f=0;c=getchar();}
	while(c>=48&&c<=57)res=(res<<3)+(res<<1)+(c&15),c=getchar();
	return f?res:-res;
}
inline void write(int x){
	register char c[21],len=0;
	if(!x)return putchar('0'),void();
	if(x<0)x=-x,putchar('-');
	while(x)c[++len]=x%10,x/=10;
	while(len)putchar(c[len--]+48);
}
#define space(x) write(x),putchar(' ')
#define enter(x) write(x),putchar('\n')

const int N=2e5+10;
int n,a[N];
ll f[N][3][2];
inline ll cmx(ll& a,ll b){a=a>b?a:b;}
int main(){
	n=read();
	for(int i=1;i<=n;++i)a[i]=read();
	memset(f,192,sizeof(f));
	f[0][0][1]=0;
	for(int i=0;i<n;++i)
		for(int j=0;j<3;++j){
			cmx(f[i+1][(j+2)%3][0],f[i][j][0]-a[i+1]);
			cmx(f[i+1][(j+1)%3][0],f[i][j][0]+a[i+1]);
			cmx(f[i+1][(j+2)%3][i&1],f[i][j][1]-a[i+1]);
			cmx(f[i+1][(j+1)%3][i&1^1],f[i][j][1]+a[i+1]);
		}
	enter(f[n][1][0]);
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
inline int read(){
	register int res=0;
	register char c=getchar(),f=1;
	while(c<48||c>57){if(c=='-')f=0;c=getchar();}
	while(c>=48&&c<=57)res=(res<<3)+(res<<1)+(c&15),c=getchar();
	return f?res:-res;
}
inline void write(ll x){
	register char c[21],len=0;
	if(!x)return putchar('0'),void();
	if(x<0)x=-x,putchar('-');
	while(x)c[++len]=x%10,x/=10;
	while(len)putchar(c[len--]+48);
}
#define space(x) write(x),putchar(' ')
#define enter(x) write(x),putchar('\n')

const int N=2e5+10;
int n,a[N];
ll f[N][3][2];
inline ll cmx(ll& a,ll b){a=a>b?a:b;}
int main(){
	n=read();
	for(int i=1;i<=n;++i)a[i]=read();
	if(n==1)return enter(a[1]),0;
	memset(f,192,sizeof(f));
	f[0][0][1]=0;
	for(int i=0;i<n;++i)
		for(int j=0;j<3;++j){
			cmx(f[i+1][(j+2)%3][0],f[i][j][0]-a[i+1]);
			cmx(f[i+1][(j+1)%3][0],f[i][j][0]+a[i+1]);
			cmx(f[i+1][(j+2)%3][i&1],f[i][j][1]-a[i+1]);
			cmx(f[i+1][(j+1)%3][i&1^1],f[i][j][1]+a[i+1]);
		}
	enter(f[n][1][0]);
}


#include<cstdio>
#include<iostream>
#include<queue>
#include<algorithm>
#include<cstring>
#include<set>
#include<vector>
#define PII pair<int,int>
#define pb push_back
#define ep emplace_back
#define mp make_pair
#define fi first
#define int long long
#define se second
using namespace std;
inline int read(){
	int x=0,f=1;char c=getchar();
	while(c<'0'||c>'9'){ if(c=='-') f=-1; c=getchar();}
	while(c>='0'&&c<='9'){x=(x<<3)+(x<<1)+(c^48);c=getchar();}
	return f==1?x:-x;
}
inline void print(int x){
	if(x<0) putchar('-'),x=~x+1;
	if(x>=10) print(x/10);
	putchar((x%10)|48);
}
int n;
int a[200010];
int dp[200010][4][3];
void gmax(int &x,int y){
	x=max(x,y);
}
signed main(){
	n=read();
	for(int i=1;i<=n;++i) a[i]=read();
	if(n==1){
		printf("%lld\n",a[1]);return 0;
	}
	memset(dp,-0x3f,sizeof(dp));
	dp[0][0][0]=0;
	for(int i=0;i<n;++i){
		for(int j=0;j<3;++j){
			for(int k=0;k<2;++k){
				if(dp[i][j][k]>-0x151515153f3f3f3f){
					gmax(dp[i+1][(j+1)%3][k|((j+1)%3==2)],dp[i][j][k]+a[i+1]);
					gmax(dp[i+1][(j+2)%3][k|((j+2)%3==2)],dp[i][j][k]-a[i+1]);

				}
			}
		}
	}
	printf("%lld\n",dp[n][1][1]);
}


#include<cstdio>
#include<iostream>
#include<queue>
#include<algorithm>
#include<cstring>
#include<set>
#include<vector>
#define PII pair<int,int>
#define pb push_back
#define ep emplace_back
#define mp make_pair
#define fi first
#define int long long
#define se second
using namespace std;
inline int read(){
	int x=0,f=1;char c=getchar();
	while(c<'0'||c>'9'){ if(c=='-') f=-1; c=getchar();}
	while(c>='0'&&c<='9'){x=(x<<3)+(x<<1)+(c^48);c=getchar();}
	return f==1?x:-x;
}
inline void print(int x){
	if(x<0) putchar('-'),x=~x+1;
	if(x>=10) print(x/10);
	putchar((x%10)|48);
}
int n;
int a[200010];
int dp[200010][4][3];
void gmax(int &x,int y){
	x=max(x,y);
}
signed main(){
	n=read();
	for(int i=1;i<=n;++i) a[i]=read();
	if(n==1){
		printf("%lld\n",a[1]);return 0;
	}
	memset(dp,-0x3f,sizeof(dp));
	dp[0][0][0]=0;
	for(int i=0;i<n;++i){
		for(int j=0;j<3;++j){
			for(int k=0;k<2;++k){
				if(dp[i][j][k]>-0x15153f3f){
					gmax(dp[i+1][(j+1)%3][k|((j+1)%3==2)],dp[i][j][k]+a[i+1]);
					gmax(dp[i+1][(j+2)%3][k|((j+2)%3==2)],dp[i][j][k]-a[i+1]);

				}
			}
		}
	}
	printf("%lld\n",dp[n][1][1]);
}


#include <bits/stdc++.h>
#define FOR(i,a,b) for(register int i=(a);i<(b);++i)
#define ROF(i,a,b) for(register int i=(a);i>=(b);--i)
#define pi pair<int,int>
#define mk(a,b) make_pair(a,b)
#define fi first
#define se second
#define ls(x) ch[x][0]
#define rs(x) ch[x][1]
#define xs(x) (ch[fa[x]][1]==x)
using namespace std;
typedef long long ll;
typedef double db;
typedef long double ldb;
typedef unsigned int ui;
typedef unsigned long long ul;
typedef long long ll;
typedef int n_;
const int maxn = 100005;
const int maxm = 1000005;
const int maxlog = 63;
const int inf = 2147483647;
const double eps = 1e-9;
const double E = 2.718281828459;
const double PI = 3.1415926576;
const long long INF = 9223372036854775807ll;
inline ll qpow(ll a,ll b,ll c){register ll ans=1;while(b){if(b&1)ans=ans*a%c;a=a*a%c;b>>=1;}return ans;}
const int mod = 1e9+7;int inv6=qpow(6,mod-2,mod);
inline void dec(n_ &x,n_ y){x-=y,x<0&&(x+=mod);}
inline void add(n_ &x,n_ y){x+=y,x>=mod&&(x-=mod);}
//inline n_ sum(n_ x,n_ y){return x+y<mod?x+y:x+y-mod;}
inline n_ sub(n_ x,n_ y){return x-y<0?x-y+mod:x-y;}
inline n_ sqr(n_ x){return 1ll*x*x%mod;}
inline n_ sm1(n_ x){return (1ll*x*(x+1)>>1)%mod;}
inline n_ sm2(n_ x){return 1ll*x*(x+1)%mod*(2*x+1)%mod*inv6%mod;}
inline n_ sm3(n_ x){return 1ll*sqr(x)*sqr(x+1)%mod;}
namespace IO{
	#define getchar() (tt == ss && (tt = (ss = In) + fread(In, 1, 1 << 20, stdin), ss == tt) ? EOF : *ss++)
	char In[1 << 20], *ss=In, *tt=In;//In����Ҫ�������������Ĵ�С
	const int END = 2147483647;//������
	//��������
	inline n_ rd(){//�޸�һ�±������ͼ���(int\ll\ul\ui)
		n_ x=0;int fg=1;
		char c=getchar();
		while(c==' ' || c=='\n')c=getchar();
		if(c=='-')fg=-1,c=getchar();
		while(isdigit(c)){
			x=(x<<3)+(x<<1)+(c-48);
			c=getchar();
		}
		return x*fg;
	}
	//�ַ�������
	inline int rds(char *s){
		register int len=0;
		register char c=getchar();
		while(c==' ' || c=='\n')c=getchar();
		while(c!=' ' && c!='\n' && c!='EOF'){
			s[len++]=c;
			c=getchar();
		}
		return len;
	}
	//����һ���ַ���
	inline int getline(char *s){
		register int len=0;
		register char c=getchar();
		while(c==' ' || c=='\n')c=getchar();
		while(c!='\n' && c!='EOF'){
			s[len++]=c;
			c=getchar();
		}
		return len;
	}
	//�������
	inline void wr(register n_ x){//���ӻ��з�
		if(x<0)putchar('-'),x=-x;
		if(x>=10)wr(x/10);
		putchar(x%10+'0');
	}
	inline void wrn(register n_ x){//�ӻ��з�
		wr(x);
		putchar('\n');
	}
	//��������ʽ�����
	inline void wrd(register n_ x,register int d){//���ӻ��з�
		if(!x){putchar('0');return;}
		register n_ xx =x;
		while(xx)d--,xx/=10;
		FOR(i,0,d)putchar('0');
		wr(x);
	}
	inline void wrdn(register n_ x,register int d){//�ӻ��з�
		wrd(x,d);
		putchar('\n');
	}
	//�ַ������
	inline void wrs(const char *s){//��������з�
		for(register int i=0;s[i];++i)putchar(s[i]);
	}
	inline void wrsn(const char *s){//������з�
		wrs(s);
		putchar('\n');
	}
	inline void debug(const char *s,n_ a=END,n_ b=END,n_ c=END,n_ d=END,n_ e=END,n_ f=END){
		if(s!=NULL)wrs(s),putchar(' ');
		if(a!=END)wr(a),putchar(' ');
		if(b!=END)wr(b),putchar(' ');
		if(c!=END)wr(c),putchar(' ');
		if(d!=END)wr(d),putchar(' ');
		if(e!=END)wr(e),putchar(' ');
		if(f!=END)wr(f),putchar(' ');
		putchar('\n');
	}
}
using namespace IO;

ll a[maxn],dp[maxn][3][2][2];

int main(){
	int n=rd();
	FOR(i,1,n+1)a[i]=rd();
	memset(dp,-0x3f,sizeof(dp));
	dp[1][2][0][0]=-a[1];
	dp[1][1][1][0]=a[1];
	FOR(i,1,n){
		FOR(j,0,3){
			FOR(l,0,2)
			FOR(k,0,2){
				dp[i+1][(j+2)%3][0][k|(l==0)]=max(dp[i+1][(j+2)%3][0][k|(l==0)],dp[i][j][l][k]-a[i+1]);
				dp[i+1][(j+1)%3][1][k|(l==1)]=max(dp[i+1][(j+1)%3][1][k|(l==1)],dp[i][j][l][k]+a[i+1]);
			}
		}
	}
	printf("%lld\n",max(dp[n][1][1][1],dp[n][1][0][1]));
}


#include <bits/stdc++.h>
#define FOR(i,a,b) for(register int i=(a);i<(b);++i)
#define ROF(i,a,b) for(register int i=(a);i>=(b);--i)
#define pi pair<int,int>
#define mk(a,b) make_pair(a,b)
#define fi first
#define se second
#define ls(x) ch[x][0]
#define rs(x) ch[x][1]
#define xs(x) (ch[fa[x]][1]==x)
using namespace std;
typedef long long ll;
typedef double db;
typedef long double ldb;
typedef unsigned int ui;
typedef unsigned long long ul;
typedef long long ll;
typedef int n_;
const int maxn = 100005;
const int maxm = 1000005;
const int maxlog = 63;
const int inf = 2147483647;
const double eps = 1e-9;
const double E = 2.718281828459;
const double PI = 3.1415926576;
const long long INF = 9223372036854775807ll;
inline ll qpow(ll a,ll b,ll c){register ll ans=1;while(b){if(b&1)ans=ans*a%c;a=a*a%c;b>>=1;}return ans;}
const int mod = 1e9+7;int inv6=qpow(6,mod-2,mod);
inline void dec(n_ &x,n_ y){x-=y,x<0&&(x+=mod);}
inline void add(n_ &x,n_ y){x+=y,x>=mod&&(x-=mod);}
//inline n_ sum(n_ x,n_ y){return x+y<mod?x+y:x+y-mod;}
inline n_ sub(n_ x,n_ y){return x-y<0?x-y+mod:x-y;}
inline n_ sqr(n_ x){return 1ll*x*x%mod;}
inline n_ sm1(n_ x){return (1ll*x*(x+1)>>1)%mod;}
inline n_ sm2(n_ x){return 1ll*x*(x+1)%mod*(2*x+1)%mod*inv6%mod;}
inline n_ sm3(n_ x){return 1ll*sqr(x)*sqr(x+1)%mod;}
namespace IO{
	#define getchar() (tt == ss && (tt = (ss = In) + fread(In, 1, 1 << 20, stdin), ss == tt) ? EOF : *ss++)
	char In[1 << 20], *ss=In, *tt=In;//In����Ҫ�������������Ĵ�С
	const int END = 2147483647;//������
	//��������
	inline n_ rd(){//�޸�һ�±������ͼ���(int\ll\ul\ui)
		n_ x=0;int fg=1;
		char c=getchar();
		while(c==' ' || c=='\n')c=getchar();
		if(c=='-')fg=-1,c=getchar();
		while(isdigit(c)){
			x=(x<<3)+(x<<1)+(c-48);
			c=getchar();
		}
		return x*fg;
	}
	//�ַ�������
	inline int rds(char *s){
		register int len=0;
		register char c=getchar();
		while(c==' ' || c=='\n')c=getchar();
		while(c!=' ' && c!='\n' && c!='EOF'){
			s[len++]=c;
			c=getchar();
		}
		return len;
	}
	//����һ���ַ���
	inline int getline(char *s){
		register int len=0;
		register char c=getchar();
		while(c==' ' || c=='\n')c=getchar();
		while(c!='\n' && c!='EOF'){
			s[len++]=c;
			c=getchar();
		}
		return len;
	}
	//�������
	inline void wr(register n_ x){//���ӻ��з�
		if(x<0)putchar('-'),x=-x;
		if(x>=10)wr(x/10);
		putchar(x%10+'0');
	}
	inline void wrn(register n_ x){//�ӻ��з�
		wr(x);
		putchar('\n');
	}
	//��������ʽ�����
	inline void wrd(register n_ x,register int d){//���ӻ��з�
		if(!x){putchar('0');return;}
		register n_ xx =x;
		while(xx)d--,xx/=10;
		FOR(i,0,d)putchar('0');
		wr(x);
	}
	inline void wrdn(register n_ x,register int d){//�ӻ��з�
		wrd(x,d);
		putchar('\n');
	}
	//�ַ������
	inline void wrs(const char *s){//��������з�
		for(register int i=0;s[i];++i)putchar(s[i]);
	}
	inline void wrsn(const char *s){//������з�
		wrs(s);
		putchar('\n');
	}
	inline void debug(const char *s,n_ a=END,n_ b=END,n_ c=END,n_ d=END,n_ e=END,n_ f=END){
		if(s!=NULL)wrs(s),putchar(' ');
		if(a!=END)wr(a),putchar(' ');
		if(b!=END)wr(b),putchar(' ');
		if(c!=END)wr(c),putchar(' ');
		if(d!=END)wr(d),putchar(' ');
		if(e!=END)wr(e),putchar(' ');
		if(f!=END)wr(f),putchar(' ');
		putchar('\n');
	}
}
using namespace IO;

ll a[maxn],dp[maxn][3][2][2];

int main(){
	int n=rd();
	FOR(i,1,n+1)a[i]=rd();
	if(n==1)return wrn(a[1]),0;
	memset(dp,-0x3f,sizeof(dp));
	dp[1][2][0][0]=-a[1];
	dp[1][1][1][0]=a[1];
	FOR(i,1,n){
		FOR(j,0,3){
			FOR(l,0,2)
			FOR(k,0,2){
				dp[i+1][(j+2)%3][0][k|(l==0)]=max(dp[i+1][(j+2)%3][0][k|(l==0)],dp[i][j][l][k]-a[i+1]);
				dp[i+1][(j+1)%3][1][k|(l==1)]=max(dp[i+1][(j+1)%3][1][k|(l==1)],dp[i][j][l][k]+a[i+1]);
			}
		}
	}
	printf("%lld\n",max(dp[n][1][1][1],dp[n][1][0][1]));
}


#include <bits/stdc++.h>
#define FOR(i,a,b) for(register int i=(a);i<(b);++i)
#define ROF(i,a,b) for(register int i=(a);i>=(b);--i)
#define pi pair<int,int>
#define mk(a,b) make_pair(a,b)
#define fi first
#define se second
#define ls(x) ch[x][0]
#define rs(x) ch[x][1]
#define xs(x) (ch[fa[x]][1]==x)
using namespace std;
typedef long long ll;
typedef double db;
typedef long double ldb;
typedef unsigned int ui;
typedef unsigned long long ul;
typedef long long ll;
typedef int n_;
const int maxn = 200005;
const int maxm = 1000005;
const int maxlog = 63;
const int inf = 2147483647;
const double eps = 1e-9;
const double E = 2.718281828459;
const double PI = 3.1415926576;
const long long INF = 9223372036854775807ll;
inline ll qpow(ll a,ll b,ll c){register ll ans=1;while(b){if(b&1)ans=ans*a%c;a=a*a%c;b>>=1;}return ans;}
const int mod = 1e9+7;int inv6=qpow(6,mod-2,mod);
inline void dec(n_ &x,n_ y){x-=y,x<0&&(x+=mod);}
inline void add(n_ &x,n_ y){x+=y,x>=mod&&(x-=mod);}
//inline n_ sum(n_ x,n_ y){return x+y<mod?x+y:x+y-mod;}
inline n_ sub(n_ x,n_ y){return x-y<0?x-y+mod:x-y;}
inline n_ sqr(n_ x){return 1ll*x*x%mod;}
inline n_ sm1(n_ x){return (1ll*x*(x+1)>>1)%mod;}
inline n_ sm2(n_ x){return 1ll*x*(x+1)%mod*(2*x+1)%mod*inv6%mod;}
inline n_ sm3(n_ x){return 1ll*sqr(x)*sqr(x+1)%mod;}
namespace IO{
	#define getchar() (tt == ss && (tt = (ss = In) + fread(In, 1, 1 << 20, stdin), ss == tt) ? EOF : *ss++)
	char In[1 << 20], *ss=In, *tt=In;//In����Ҫ�������������Ĵ�С
	const int END = 2147483647;//������
	//��������
	inline n_ rd(){//�޸�һ�±������ͼ���(int\ll\ul\ui)
		n_ x=0;int fg=1;
		char c=getchar();
		while(c==' ' || c=='\n')c=getchar();
		if(c=='-')fg=-1,c=getchar();
		while(isdigit(c)){
			x=(x<<3)+(x<<1)+(c-48);
			c=getchar();
		}
		return x*fg;
	}
	//�ַ�������
	inline int rds(char *s){
		register int len=0;
		register char c=getchar();
		while(c==' ' || c=='\n')c=getchar();
		while(c!=' ' && c!='\n' && c!='EOF'){
			s[len++]=c;
			c=getchar();
		}
		return len;
	}
	//����һ���ַ���
	inline int getline(char *s){
		register int len=0;
		register char c=getchar();
		while(c==' ' || c=='\n')c=getchar();
		while(c!='\n' && c!='EOF'){
			s[len++]=c;
			c=getchar();
		}
		return len;
	}
	//�������
	inline void wr(register n_ x){//���ӻ��з�
		if(x<0)putchar('-'),x=-x;
		if(x>=10)wr(x/10);
		putchar(x%10+'0');
	}
	inline void wrn(register n_ x){//�ӻ��з�
		wr(x);
		putchar('\n');
	}
	//��������ʽ�����
	inline void wrd(register n_ x,register int d){//���ӻ��з�
		if(!x){putchar('0');return;}
		register n_ xx =x;
		while(xx)d--,xx/=10;
		FOR(i,0,d)putchar('0');
		wr(x);
	}
	inline void wrdn(register n_ x,register int d){//�ӻ��з�
		wrd(x,d);
		putchar('\n');
	}
	//�ַ������
	inline void wrs(const char *s){//��������з�
		for(register int i=0;s[i];++i)putchar(s[i]);
	}
	inline void wrsn(const char *s){//������з�
		wrs(s);
		putchar('\n');
	}
	inline void debug(const char *s,n_ a=END,n_ b=END,n_ c=END,n_ d=END,n_ e=END,n_ f=END){
		if(s!=NULL)wrs(s),putchar(' ');
		if(a!=END)wr(a),putchar(' ');
		if(b!=END)wr(b),putchar(' ');
		if(c!=END)wr(c),putchar(' ');
		if(d!=END)wr(d),putchar(' ');
		if(e!=END)wr(e),putchar(' ');
		if(f!=END)wr(f),putchar(' ');
		putchar('\n');
	}
}
using namespace IO;

ll a[maxn],dp[maxn][3][2][2];

int main(){
	int n=rd();
	FOR(i,1,n+1)a[i]=rd();
	if(n==1)return wrn(a[1]),0;
	memset(dp,-0x3f,sizeof(dp));
	dp[1][2][0][0]=-a[1];
	dp[1][1][1][0]=a[1];
	FOR(i,1,n){
		FOR(j,0,3){
			FOR(l,0,2)
			FOR(k,0,2){
				dp[i+1][(j+2)%3][0][k|(l==0)]=max(dp[i+1][(j+2)%3][0][k|(l==0)],dp[i][j][l][k]-a[i+1]);
				dp[i+1][(j+1)%3][1][k|(l==1)]=max(dp[i+1][(j+1)%3][1][k|(l==1)],dp[i][j][l][k]+a[i+1]);
			}
		}
	}
	printf("%lld\n",max(dp[n][1][1][1],dp[n][1][0][1]));
}


#include <bits/stdc++.h>
using namespace std;
template<class T>inline bool read(T &x){
	x=0;register char ch=getchar();register bool f=0;
	while(!isdigit(ch)){
		if (ch==EOF) return 0;
		f^=ch=='-';
		ch=getchar();
	}while(isdigit(ch)){
		x=(x<<1)+(x<<3)+(ch^48);
		ch=getchar();
	}if (f) x=-x;
	return 1;
}
template<class T,class ...S>inline bool read(T &x,S &...y){
	return read(x)&&read(y...);
}
template<class T>inline void write(T x){
	if (x<0) x=-x,putchar('-');
	if (x>9) write(x/10);
	putchar(x%10^48);
	return;
}
template<class T>inline void write(T x,char ch){
	write(x);
	putchar(ch);
	return;
}

long long sum[200005],f[200005][3],a[200005];
int n;

int main(){
	read(n);
	for (int i=1;i<=n;i++)
	read(a[i]);
	if (n==1){
		write(a[1]);
		return 0;
	}
	sum[1]=a[1];
	for (int i=1;i<=n;i++)
	for (int j=0;j<=2;j++)
	f[i][j]=-2e14;
	f[1][1]=-a[1];
	for (int i=2;i<=n;i++){
		if (i&1) sum[i]=sum[i-1]+a[i],f[i][(i/2+1)%3]=sum[i-1]-a[i];
		else sum[i]=sum[i-1]-a[i],f[i][(i/2-1)%3]=sum[i-1]+a[i];
		for (int j=0;j<=2;j++)
		f[i][j]=max(f[i-1][j]+a[i],f[i][j]),
		f[i][(j+1)%3]=max(f[i-1][j]-a[i],f[i][(j+1)%3]);
	}
	write(f[n][(4-n%3)%3]);
}


#include <bits/stdc++.h>
using namespace std;
template<class T>inline bool read(T &x){
	x=0;register char ch=getchar();register bool f=0;
	while(!isdigit(ch)){
		if (ch==EOF) return 0;
		f^=ch=='-';
		ch=getchar();
	}while(isdigit(ch)){
		x=(x<<1)+(x<<3)+(ch^48);
		ch=getchar();
	}if (f) x=-x;
	return 1;
}
template<class T,class ...S>inline bool read(T &x,S &...y){
	return read(x)&&read(y...);
}
template<class T>inline void write(T x){
	if (x<0) x=-x,putchar('-');
	if (x>9) write(x/10);
	putchar(x%10^48);
	return;
}
template<class T>inline void write(T x,char ch){
	write(x);
	putchar(ch);
	return;
}

long long sum[200005],f[200005][3],a[200005];
int n;

int main(){
	read(n);
	for (int i=1;i<=n;i++)
	read(a[i]);
	sum[1]=a[1];
	for (int i=1;i<=n;i++)
	for (int j=0;j<=2;j++)
	f[i][j]=-2e14;
	f[1][1]=-a[1];
	for (int i=2;i<=n;i++){
		if (i&1) sum[i]=sum[i-1]+a[i],f[i][(i/2+1)%3]=sum[i-1]-a[i];
		else sum[i]=sum[i-1]-a[i],f[i][(i/2-1)%3]=sum[i-1]+a[i];
		for (int j=0;j<=2;j++)
		f[i][j]=max(f[i-1][j]+a[i],f[i][j]),
		f[i][(j+1)%3]=max(f[i-1][j]-a[i],f[i][(j+1)%3]);
	}
	write(f[n][(4-n%3)%3]);
}


#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math")
#include <bits/stdc++.h>
using namespace std;
template<class t> inline t read(t &x){
	char c=getchar();bool f=0;x=0;
	while(!isdigit(c)) f|=c=='-',c=getchar();
	while(isdigit(c)) x=(x<<1)+(x<<3)+(c^48),c=getchar();
	if(f) x=-x;return x;
}
template<class t,class ...A> inline void read(t &x,A &...a){
	read(x);read(a...);
}
template<class t> inline void write(t x){
	if(x<0) putchar('-'),write(-x);
	else{if(x>9) write(x/10);putchar('0'+x%10);}
}

#define int long long

const int N=2e5+5;
int f[N][3][2],n,a[N];

void smax(int &x,int y){
	x=x>y?x:y;
}

signed main(){
	read(n);
	for(int i=1;i<=n;i++) read(a[i]);
	if(n==1) return write(a[1]),0;
	memset(f,0xf3,sizeof f);
	f[0][0][1]=0;
	for(int i=0;i<n;i++) for(int j=0;j<3;j++){
		smax(f[i+1][(j+2)%3][0],f[i][j][0]-a[i+1]);
		smax(f[i+1][(j+1)%3][0],f[i][j][0]+a[i+1]);
		smax(f[i+1][(j+2)%3][i&1],f[i][j][1]-a[i+1]);
		smax(f[i+1][(j+1)%3][~i&1],f[i][j][1]+a[i+1]);
	}
	write(f[n][1][0]);
}


#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math")
#include <bits/stdc++.h>
using namespace std;
template<class t> inline t read(t &x){
	char c=getchar();bool f=0;x=0;
	while(!isdigit(c)) f|=c=='-',c=getchar();
	while(isdigit(c)) x=(x<<1)+(x<<3)+(c^48),c=getchar();
	if(f) x=-x;return x;
}
template<class t,class ...A> inline void read(t &x,A &...a){
	read(x);read(a...);
}
template<class t> inline void write(t x){
	if(x<0) putchar('-'),write(-x);
	else{if(x>9) write(x/10);putchar('0'+x%10);}
}

#define int long long

const int N=2e5+5;
int f[N][3][2],n,a[N];

void smax(int &x,int y){
	x=x>y?x:y;
}

signed main(){
	read(n);
	for(int i=1;i<=n;i++) read(a[i]);
	if(n==1) return write(a[1]),0;
	for(int i=0;i<n;i++) for(int j=0;j<3;j++){
		smax(f[i+1][(j+2)%3][0],f[i][j][0]-a[i+1]);
		smax(f[i+1][(j+1)%3][0],f[i][j][0]+a[i+1]);
		smax(f[i+1][(j+2)%3][i&1],f[i][j][1]-a[i+1]);
		smax(f[i+1][(j+1)%3][~i&1],f[i][j][1]+a[i+1]);
	}
	write(f[n][1][0]);
}


#include<bits/stdc++.h>
#define int long long
using namespace std;
const int N=2e5+7;
int a[N],ind[N],sum;
bool sgn[N];

int32_t main()
{
  int n;
  scanf("%lld",&n);
  for(int i=0;i<n;i++)
    {
      scanf("%lld",a+i);
      sum+=a[i];
      ind[i]=i;
    }
  sort(ind,ind+n,[&](int i,int j){return a[i]<a[j];});
  int ans=(n%3==1?sum:-(1e15));
  int m=0;
  bool ok=false;
  for(int i=0;i<n;i++)
    {
      sum-=2*a[ind[i]];
      m++;
      int k=ind[i];
      sgn[k]=true;
      ok|=(sgn[k]==sgn[k+1]||(k!=0&&sgn[k-1]==sgn[k]));
      if((n+m)%3==1)
	{
	  if(abs(n-2*m)>1||ok)
	    ans=max(ans,sum);
	  else
	    ans=max(ans,sum+2*(a[k]-a[ind[i+1]]));
	}
    }
  printf("%lld\n",ans);
}


#include<bits/stdc++.h>
#define int long long
using namespace std;
const int N=2e5+7;
int a[N],ind[N],sum;
bool sgn[N];

int32_t main()
{
  int n;
  scanf("%lld",&n);
  for(int i=0;i<n;i++)
    {
      scanf("%lld",a+i);
      sum+=a[i];
      ind[i]=i;
    }
  sort(ind,ind+n,[&](int i,int j){return a[i]<a[j];});
  int ans=(n%3==1?sum:-(1e18));
  int m=0;
  bool ok=false;
  for(int i=0;i<n;i++)
    {
      sum-=2*a[ind[i]];
      m++;
      int k=ind[i];
      sgn[k]=true;
      ok|=(sgn[k]==sgn[k+1]||(k!=0&&sgn[k-1]==sgn[k]));
      if((n+m)%3==1)
	{
	  if(abs(n-2*m)>1||ok)
	    ans=max(ans,sum);
	  else
	    ans=max(ans,sum+2*(a[k]-a[ind[i+1]]));
	}
    }
  printf("%lld\n",ans);
}


#include<bits/stdc++.h>
#define int long long
using namespace std;
const int N=2e5+7;
int a[N],ind[N],sum;
bool sgn[N];

int32_t main()
{
  int n;
  scanf("%lld",&n);
  for(int i=0;i<n;i++)
    {
      scanf("%lld",a+i);
      sum+=a[i];
      ind[i]=i;
    }

  sort(ind,ind+n,[&](int i,int j){return a[i]<a[j];});
  int ans=(n%3==1?sum:-(1e18));
  int m=0;
  for(int i=0;i<n;i++)
    {
      sum-=2*a[ind[i]];
      m++;
      int k=ind[i];
      sgn[k]=true;
      if((n+m)%3==1)
	{
	  if(abs(n-2*m)>1)
	    ans=max(ans,sum);
	  else
	    {
	      bool ok=false;
	      for(int j=0;j<n-1;j++)
		if(sgn[j]==sgn[j+1])
		  {
		    ok=true;
		    break;
		  }
	      if(ok)
		ans=max(ans,sum);
	      else
		ans=max(ans,sum+2*(a[k]-a[ind[i+1]]));
	    }
	}
    }
  printf("%lld\n",ans);
}


#include<bits/stdc++.h>
#define int long long
using namespace std;
const int N=2e5+7;
int a[N],ind[N],sum;
bool sgn[N];

int32_t main()
{
  int n;
  scanf("%lld",&n);
  for(int i=0;i<n;i++)
    {
      scanf("%lld",a+i);
      sum+=a[i];
      ind[i]=i;
    }

  sort(ind,ind+n,[&](int i,int j){return a[i]<a[j];});
  int ans=(n%3==1?sum:-(1e18));
  int m=0;
  bool ok=false;
  for(int i=0;i<n;i++)
    {
      sum-=2*a[ind[i]];
      m++;
      int k=ind[i];
      sgn[k]=true;
      ok|=(sgn[k]==sgn[k+1]||(k!=0&&sgn[k-1]==sgn[k]));
      if((n+m)%3==1)
	{
	  if(abs(n-2*m)>1)
	    ans=max(ans,sum);
	  else
	    if(ok)
	      ans=max(ans,sum);
	    else
	      ans=max(ans,sum+2*(a[k]-a[ind[i+1]]));
	}
    }
  printf("%lld\n",ans);
}


#include<bits/stdc++.h>
#define int long long
using namespace std;
const int N=2e5+7;
int a[N],ind[N],sum;
bool sgn[N];

int32_t main()
{
  int n;
  scanf("%lld",&n);
  for(int i=0;i<n;i++)
    {
      scanf("%lld",a+i);
      sum+=a[i];
      ind[i]=i;
    }

  sort(ind,ind+n,[&](int i,int j){return a[i]<a[j];});
  int ans=(n%3==1?sum:-(1e18));
  int m=0;
  bool ok=false;
  for(int i=0;i<n;i++)
    {
      sum-=2*a[ind[i]];
      m++;
      int k=ind[i];
      sgn[k]=true;
      ok|=(sgn[k]==sgn[k+1]||(k!=0&&sgn[k-1]==sgn[k]));
      if((n+m)%3==1)
	{
	  if(abs(n-2*m)>1)
	    ans=max(ans,sum);
	  else
	    {
	      vector<bool>check(n);
	      for (int j = 0; j <= i; ++j)
		check[ind[j]] = true;
	      ok = false;
	      for (int j = 0; j + 1 < n; ++j)
		if (check[j] == check[j + 1]) {
		  ok = true;
		  break;
		}
	      if(ok)
		ans=max(ans,sum);
	      else
		ans=max(ans,sum+2*(a[k]-a[ind[i+1]]));
	    }
	}
    }
  printf("%lld\n",ans);
}


#include<bits/stdc++.h>
#define int long long
using namespace std;
const int N=2e5+7;
int a[N],ind[N],sum;
bool sgn[N];

int32_t main()
{
  int n;
  scanf("%lld",&n);
  for(int i=0;i<n;i++)
    {
      scanf("%lld",a+i);
      sum+=a[i];
      ind[i]=i;
    }

  sort(ind,ind+n,[&](int i,int j){return a[i]<a[j];});
  int ans=(n%3==1?sum:-(1e18));
  int m=0;
  bool ok=false;
  for(int i=0;i<n;i++)
    {
      sum-=2*a[ind[i]];
      m++;
      int k=ind[i];
      sgn[k]=true;
      ok|=(sgn[k]==sgn[k+1]||(k!=0&&sgn[k-1]==sgn[k]));
      if((n+m)%3==1)
	{
	  if(abs(n-2*m)>1)
	    ans=max(ans,sum);
	  else
	    {
	      vector<bool>check(n)
	      for (int j = 0; j <= i; ++j)
		check[ind[j]] = true;
	      ok = false;
	      for (int j = 0; j + 1 < n; ++j)
		if (check[j] == check[j + 1]) {
		  ok = true;
		  break;
		}
	      if(ok)
		ans=max(ans,sum);
	      else
		ans=max(ans,sum+2*(a[k]-a[ind[i+1]]));
	    }
	}
    }
  printf("%lld\n",ans);
}


#include<bits/stdc++.h>
#define int long long
using namespace std;
const int N=2e5+7;
int a[N],ind[N],sum;
bool sgn[N];

int32_t main()
{
  int n;
  scanf("%lld",&n);
  for(int i=0;i<n;i++)
    {
      scanf("%lld",a+i);
      sum+=a[i];
      ind[i]=i;
    }
  sort(ind,ind+n,[&](int i,int j){return a[i]<a[j];});
  int ans=(n%3==1?sum:-(1e15));
  int m=0;
  bool ok=false;
  for(int i=0;i<n;i++)
    {
      sum-=2*a[ind[i]];
      m++;
      int k=ind[i];
      sgn[k]=true;
      if(sgn[k]==sgn[k+1]||(k&&sgn[k-1]==sgn[k]))
	 ok=true;
      if((n+m)%3==1)
	{
	  if(n-2*m>1||ok)
	    ans=max(ans,sum);
	  else
	    ans=max(ans,sum+2*(a[k]-a[ind[i+1]]));
	}
    }
  printf("%lld\n",ans);
}


#include<stdio.h>
#include<string.h>
#define it register int
#define ct const int
#define il inline
using namespace std;
typedef long long ll;
#define rll register ll
#define cll const ll
const int N=1000005;
int n,a[N];
ll f[N][3][2];
il int Min(ct p,ct q){return p<q?p:q;}
template<class I>
il void ckMax(I&p,I q){p=(p>q?p:q);}
int main(){
	//freopen("a.in","r",stdin);
	//freopen("a.out","w",stdout);
	scanf("%d",&n);it i,j;
	for(i=1;i<=n;++i) scanf("%d",&a[i]);
	if(n==1) return printf("%d",a[1]),0;
	memset(f,-0x3f,sizeof(f)),f[0][0][1]=0;
	for(i=1;i<=n;++i)
		for(j=0;j<3;++j)
			ckMax(f[i][(j+1)%3][0],f[i-1][j][0]+a[i]),ckMax(f[i][(j+2)%3][0],f[i-1][j][0]-a[i]),ckMax(f[i][(j+1)%3][i&1],f[i-1][j][1]+a[i]),ckMax(f[i][(j+2)%3][i-1&1],f[i-1][j][1]-a[i]);
	printf("%lld",f[n][1][0]);
	return 0;
}


#pragma GCC optimize(2)
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
#define re register
#define ri register int
#define rl register ll
#define For(i,a,b) for(ri i=a;i<=b;++i)
#define iFor(i,a,b) for(ri i=a;i>=b;--i)
#define gtch() (_p1==_p2&&(_p2=(_p1=buf)+fread(buf,1,1<<22,stdin),_p1==_p2)?EOF:*_p1++)
#define File(x) freopen(x".in","r",stdin),freopen(x".out","w",stdout);
#define I inline int
#define V inline void
#define LL inline ll
using namespace std;
typedef long long ll;
char buf[1<<22],*_p1=buf,*_p2=buf;
LL fr(){
	rl r=0;re char c=gtch();ri b=0;
	while(!isdigit(c))b=(c=='-'),c=gtch();
	while(isdigit(c))r=r*10+c-'0',c=gtch();
	return b?-r:r;
}
const ll INFl=9e17;
const int N=2e6+5;
ll dp[N][3][2][2];
ll ar[N];
int n;
V prc(){
	if(n==1){cout<<ar[1];return ;}
	memset(dp,0xcf,sizeof(dp));
	dp[1][2][1][0]=-ar[1];
	dp[1][1][0][0]=ar[1];
	For(i,1,n-1)For(j,0,2)For(cur,0,1)For(nxt,0,1)

	dp[i+1][(j+1+nxt)%3][nxt][cur==nxt]=max(dp[i+1][(j+1+nxt)%3][nxt][cur==nxt],dp[i][j][cur][0]+(nxt?-ar[i+1]:ar[i+1])),

	dp[i+1][(j+1+nxt)%3][nxt][1]=max(dp[i+1][(j+1+nxt)%3][nxt][1],dp[i][j][cur][1]+(nxt?-ar[i+1]:ar[i+1]))

//	,cerr<<i+1<<" "<< (j+1+nxt)%3<<" "<<nxt<<" "<<(cur==nxt)<<" "<<dp[i+1][(j+1+nxt)%3][nxt][cur==nxt]<<"\n"
//	,cerr<<i+1<<" "<< (j+1+nxt)%3<<" "<<nxt<<" "<<1<<" "<<dp[i+1][(j+1+nxt)%3][nxt][1]<<"\n"

	;

	cout<<max(dp[n][1][1][1],dp[n][1][0][1]);

}
V input(){
	n=fr();
	For(i,1,n)ar[i]=fr();
}
signed main(){
//	File("sequence")
	input();
	prc();
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define L(i, j, k) for(int i = (j), i##E = (k); i <= i##E; i++)
#define R(i, j, k) for(int i = (j), i##E = (k); i >= i##E; i--)
#define ll long long
#define ull unsigned long long
#define db long double
#define mp make_pair
const int N = 2e5 + 7;
const ll INF = 1e18;
int n, m, a[N], cnta, cntb;
ll dp[N][3], fla, flb;
void Max(ll &x, ll y) { x = (x > y ? x : y); }
int main() {
    scanf("%d%d", &n, &a[1]), fla = a[1], flb = -a[1], cntb = 1;
    if(n == 1) return printf("%d\n", a[1]), 0;
    dp[1][0] = dp[1][1] = dp[1][2] = -INF;
    L(i, 2, n) {
        dp[i][0] = dp[i][1] = dp[i][2] = -INF;
        scanf("%d", &a[i]);
        if(i % 2 == 0) {
            Max(dp[i][cnta % 3], fla + a[i]), fla -= a[i], cnta++;
            Max(dp[i][(cntb + 1) % 3], flb - a[i]), flb += a[i];
        }
        else {
            Max(dp[i][(cnta + 1) % 3], fla - a[i]), fla += a[i];
            Max(dp[i][cntb % 3], flb + a[i]), flb -= a[i], cntb++;
        }
        Max(dp[i][0], dp[i - 1][2] - a[i]);
        Max(dp[i][1], dp[i - 1][0] - a[i]);
        Max(dp[i][2], dp[i - 1][1] - a[i]);
        Max(dp[i][0], dp[i - 1][0] + a[i]);
        Max(dp[i][1], dp[i - 1][1] + a[i]);
        Max(dp[i][2], dp[i - 1][2] + a[i]);
    }
    printf("%lld\n", dp[n][(1 + 2 * n) % 3]);
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define L(i, j, k) for(int i = (j), i##E = (k); i <= i##E; i++)
#define R(i, j, k) for(int i = (j), i##E = (k); i >= i##E; i--)
#define ll long long
#define ull unsigned long long
#define db long double
#define mp make_pair
const int N = 2e5 + 7;
const ll INF = 1e18;
int n, m, a[N], cnta, cntb;
ll dp[N][3], fla, flb;
void Max(ll &x, ll y) { x = (x > y ? x : y); }
int main() {
    scanf("%d%d", &n, &a[1]), fla = a[1], flb = -a[1], cntb = 1;
    dp[1][0] = dp[1][1] = dp[1][2] = -INF;
    L(i, 2, n) {
        dp[i][0] = dp[i][1] = dp[i][2] = -INF;
        scanf("%d", &a[i]);
        if(i % 2 == 0) {
            Max(dp[i][cnta % 3], fla + a[i]), fla -= a[i], cnta++;
            Max(dp[i][(cntb + 1) % 3], flb - a[i]), flb += a[i];
        }
        else {
            Max(dp[i][(cnta + 1) % 3], fla - a[i]), fla += a[i];
            Max(dp[i][cntb % 3], flb + a[i]), flb -= a[i], cntb++;
        }
        Max(dp[i][0], dp[i - 1][2] - a[i]);
        Max(dp[i][1], dp[i - 1][0] - a[i]);
        Max(dp[i][2], dp[i - 1][1] - a[i]);
        Max(dp[i][0], dp[i - 1][0] + a[i]);
        Max(dp[i][1], dp[i - 1][1] + a[i]);
        Max(dp[i][2], dp[i - 1][2] + a[i]);
    }
    printf("%lld\n", dp[n][(1 + 2 * n) % 3]);
    return 0;
}


#include <cstdio>
#include <cassert>
#include <cstring>
#include <cstdlib>
#include <string>
#include <iostream>
#include <vector>
#include <queue>
#include <map>
#include <algorithm>
//#include <functional>

using namespace std;

typedef long long i64;
typedef pair<int, int> pii;

const i64 prm = 1e9 + 7;

i64 a[210000];
i64 dp[210000][3][2];
int main() {
	int n;
	cin >> n;
	for (int i = 0; i < n; ++i) {
		cin >> a[i];
	}
	i64 inf = -prm;
	inf *= prm;
	for (int i = 0; i < 3; ++i) {
		for (int j = 0; j < 2; ++j) {
			dp[0][i][j] = inf;
		}
	}
	dp[0][0][1] = a[0];
	dp[0][1][0] = -a[0];
	for (int k = 1; k < n; ++k) {
		for (int i = 0; i < 3; ++i) {
			for (int j = 0; j < 2; ++j) {
				dp[k][i][j] = inf;
			}
		}
		for (int i = 0; i < 3; ++i) {
			for (int j = 0; j < 2; ++j) {
				for (int jj = 0; jj < 2; ++jj) {
					int ni = (i + jj) % 3;
					int nj = (j && jj % 2 == k % 2);
					dp[k][ni][nj] = max(dp[k][ni][nj], dp[k-1][i][j] + (jj ? -a[k] : a[k]));
				}
			}
		}
	}
	i64 ans = inf;
	for (int i = 0; i < 3; ++i) {
		if ((i + n) % 3 == 1) {
			for (int j = 0; j < 2; ++j) {
				if (n % 2 == 1 && j == 1) {
					continue;
				}
				ans = max(ans, dp[n-1][i][j]);
			}
		}
	}
	cout << ans << endl;
	return 0;
}


#include <cstdio>
#include <cassert>
#include <cstring>
#include <cstdlib>
#include <string>
#include <iostream>
#include <vector>
#include <queue>
#include <map>
#include <algorithm>
//#include <functional>

using namespace std;

typedef long long i64;
typedef pair<int, int> pii;

const i64 prm = 1e9 + 7;

i64 a[210000];
i64 dp[210000][3][2];
int main() {
	int n;
	cin >> n;
	for (int i = 0; i < n; ++i) {
		cin >> a[i];
	}
	i64 inf = -prm;
	inf *= prm;
	for (int i = 0; i < 3; ++i) {
		for (int j = 0; j < 2; ++j) {
			dp[0][i][j] = inf;
		}
	}
	dp[0][0][1] = a[0];
	dp[0][1][0] = -a[0];
	for (int k = 1; k < n; ++k) {
		for (int i = 0; i < 3; ++i) {
			for (int j = 0; j < 2; ++j) {
				dp[k][i][j] = inf;
			}
		}
		for (int i = 0; i < 3; ++i) {
			for (int j = 0; j < 2; ++j) {
				for (int jj = 0; jj < 2; ++jj) {
					int ni = (i + jj) % 3;
					int nj = (j && jj % 2 == k % 2);
					dp[k][ni][nj] = max(dp[k][ni][nj], dp[k-1][i][j] + (jj ? -a[k] : a[k]));
				}
			}
		}
	}
	i64 ans = inf;
	for (int i = 0; i < 3; ++i) {
		if ((i + n) % 3 == 1) {
				ans = max(ans, dp[n-1][i][0]);
		}
	}
	cout << ans << endl;
	return 0;
}


#include <cstdio>
#include <cassert>
#include <cstring>
#include <cstdlib>
#include <string>
#include <iostream>
#include <vector>
#include <queue>
#include <map>
#include <algorithm>
//#include <functional>

using namespace std;

typedef long long i64;
typedef pair<int, int> pii;

const i64 prm = 1e9 + 7;

i64 a[210000];
i64 dp[210000][3][2];
int main() {
	int n;
	cin >> n;
	for (int i = 0; i < n; ++i) {
		cin >> a[i];
	}
	if (n == 1) {
		cout << a[0] << endl;
		return 0;
	}
	i64 inf = -prm;
	inf *= prm;
	for (int i = 0; i < 3; ++i) {
		for (int j = 0; j < 2; ++j) {
			dp[0][i][j] = inf;
		}
	}
	dp[0][0][1] = a[0];
	dp[0][1][0] = -a[0];
	for (int k = 1; k < n; ++k) {
		for (int i = 0; i < 3; ++i) {
			for (int j = 0; j < 2; ++j) {
				dp[k][i][j] = inf;
			}
		}
		for (int i = 0; i < 3; ++i) {
			for (int j = 0; j < 2; ++j) {
				for (int jj = 0; jj < 2; ++jj) {
					int ni = (i + jj) % 3;
					int nj = (j && jj % 2 == k % 2);
					dp[k][ni][nj] = max(dp[k][ni][nj], dp[k-1][i][j] + (jj ? -a[k] : a[k]));
				}
			}
		}
	}
	i64 ans = inf;
	for (int i = 0; i < 3; ++i) {
		if ((i + n) % 3 == 1) {
			for (int j = 0; j < 2; ++j) {
				if (n % 2 == 1 && j == 1) {
					continue;
				}
				ans = max(ans, dp[n-1][i][j]);
			}
		}
	}
	cout << ans << endl;
	return 0;
}


#include<bits/stdc++.h>
#define si(a) scanf("%d",&a)
#define sl(a) scanf("%lld",&a)
#define sd(a) scanf("%lf",&a)
#define sc(a) scanf("%c",&a)
#define ss(a) scanf("%s",a)
#define pi(a) printf("%d\n",a)
#define pl(a) printf("%lld\n",a)
#define pc(a) putchar(a)
#define ms(a) memset(a,0,sizeof(a))
#define repi(i, a, b) for(register int i=a;i<=b;++i)
#define repd(i, a, b) for(register int i=a;i>=b;--i)
#define reps(s) for(register int i=head[s];i;i=Next[i])
#define ll long long
#define ull unsigned long long
#define vi vector<int>
#define pii pair<int,int>
#define mii unordered_map<int,int>
#define msi unordered_map<string,int>
#define lowbit(x) ((x)&(-(x)))
#define ce(i, r) i==r?'\n':' '
#define pb push_back
#define fi first
#define se second
#define all(x) x.begin(),x.end()
#define INF 0x3f3f3f3f
#define pr(x) cout<<#x<<": "<<x<<endl
using namespace std;
inline int qr() {
	int f = 0, fu = 1;
	char c = getchar();
	while (c < '0' || c > '9') {
		if (c == '-')fu = -1;
		c = getchar();
	}
	while (c >= '0' && c <= '9') {
		f = (f << 3) + (f << 1) + c - 48;
		c = getchar();
	}
	return f * fu;
}
const int N=2e5+10;
ll f[N][3][2][2];
int a[N],n;
int main() {
	n=qr();
	repi(i,1,n)a[i]=qr();
	if(n==1) {
		pi(a[1]);
		return 0;
	}
	repi(i,1,n)repi(j,0,2)
	repi(k,0,1)repi(l,0,1)
	f[i][j][k][l]=-4e18;
	f[1][n%3][0][0]=a[1];
	f[1][(n+1)%3][0][1]=-a[1];
	repi(i,1,n-1)repi(j,0,2)
	repi(k,0,1)repi(l,0,1)
	if(f[i][j][k][l]>-4e18) {
		f[i+1][(j+1)%3][k|(l==1)][1]=max(f[i+1][(j+1)%3][k|(l==1)][1],f[i][j][k][l]-a[i+1]);
		f[i+1][j][k|(l==0)][0]=max(f[i+1][j][k|(l==0)][0],f[i][j][k][l]+a[i+1]);
	}
	pl(max(f[n][1][1][1],f[n][1][1][0]));
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
inline int read(){
	int s=0,f=1;char ch=getchar();
	while(!isdigit(ch)){if(ch=='-') f=-1;ch=getchar();}
	while(isdigit(ch)) s=s*10+ch-'0',ch=getchar();
	return s*f;
}
typedef long long ll;
typedef pair<int,int> pii;
const int N=2e5+5;
int n;
ll a[N],f[N][3][2];
inline void chkmax(ll &x,ll y){if(y>x) x=y;}
int main(){
	ios::sync_with_stdio(false);cin.tie(0);
	cin>>n;
	for(int i=1;i<=n;i++) cin>>a[i];
	memset(f,-0x3f,sizeof(f));
	f[0][0][0]=0;
	for(int i=0;i<n;i++){
		for(int j=0;j<3;j++)
			for(int k=0;k<2;k++){
                chkmax(f[i+1][(j+1)%3][k|((j+1)%3==2)],f[i][j][k]+a[i+1]);
                chkmax(f[i+1][(j+2)%3][k|((j+2)%3==2)],f[i][j][k]-a[i+1]);
			}
	}
	cout<<f[n][1][1];
	return 0;
}


#pragma GCC optimize(1)
#pragma GCC optimize(2)
#pragma GCC optimize(3)
#pragma GCC optimize("Ofast")
#pragma GCC optimize("inline")
#pragma GCC optimize("-fgcse")
#pragma GCC optimize("-fgcse-lm")
#pragma GCC optimize("-fipa-sra")
#pragma GCC optimize("-ftree-pre")
#pragma GCC optimize("-ftree-vrp")
#pragma GCC optimize("-fpeephole2")
#pragma GCC optimize("-ffast-math")
#pragma GCC optimize("-fsched-spec")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("-falign-jumps")
#pragma GCC optimize("-falign-loops")
#pragma GCC optimize("-falign-labels")
#pragma GCC optimize("-fdevirtualize")
#pragma GCC optimize("-fcaller-saves")
#pragma GCC optimize("-fcrossjumping")
#pragma GCC optimize("-fthread-jumps")
#pragma GCC optimize("-funroll-loops")
#pragma GCC optimize("-fwhole-program")
#pragma GCC optimize("-freorder-blocks")
#pragma GCC optimize("-fschedule-insns")
#pragma GCC optimize("inline-functions")
#pragma GCC optimize("-ftree-tail-merge")
#pragma GCC optimize("-fschedule-insns2")
#pragma GCC optimize("-fstrict-aliasing")
#pragma GCC optimize("-fstrict-overflow")
#pragma GCC optimize("-falign-functions")
#pragma GCC optimize("-fcse-skip-blocks")
#pragma GCC optimize("-fcse-follow-jumps")
#pragma GCC optimize("-fsched-interblock")
#pragma GCC optimize("-fpartial-inlining")
#pragma GCC optimize("no-stack-protector")
#pragma GCC optimize("-freorder-functions")
#pragma GCC optimize("-findirect-inlining")
#pragma GCC optimize("-frerun-cse-after-loop")
#pragma GCC optimize("inline-small-functions")
#pragma GCC optimize("-finline-small-functions")
#pragma GCC optimize("-ftree-switch-conversion")
#pragma GCC optimize("-foptimize-sibling-calls")
#pragma GCC optimize("-fexpensive-optimizations")
#pragma GCC optimize("-funsafe-loop-optimizations")
#pragma GCC optimize("inline-functions-called-once")
#pragma GCC optimize("-fdelete-null-pointer-checks")
#pragma G++ optimize(1)
#pragma G++ optimize(2)
#pragma G++ optimize(3)
#pragma G++ optimize("Ofast")
#pragma G++ optimize("inline")
#pragma G++ optimize("-fgcse")
#pragma G++ optimize("-fgcse-lm")
#pragma G++ optimize("-fipa-sra")
#pragma G++ optimize("-ftree-pre")
#pragma G++ optimize("-ftree-vrp")
#pragma G++ optimize("-fpeephole2")
#pragma G++ optimize("-ffast-math")
#pragma G++ optimize("-fsched-spec")
#pragma G++ optimize("unroll-loops")
#pragma G++ optimize("-falign-jumps")
#pragma G++ optimize("-falign-loops")
#pragma G++ optimize("-falign-labels")
#pragma G++ optimize("-fdevirtualize")
#pragma G++ optimize("-fcaller-saves")
#pragma G++ optimize("-fcrossjumping")
#pragma G++ optimize("-fthread-jumps")
#pragma G++ optimize("-funroll-loops")
#pragma G++ optimize("-fwhole-program")
#pragma G++ optimize("-freorder-blocks")
#pragma G++ optimize("-fschedule-insns")
#pragma G++ optimize("inline-functions")
#pragma G++ optimize("-ftree-tail-merge")
#pragma G++ optimize("-fschedule-insns2")
#pragma G++ optimize("-fstrict-aliasing")
#pragma G++ optimize("-fstrict-overflow")
#pragma G++ optimize("-falign-functions")
#pragma G++ optimize("-fcse-skip-blocks")
#pragma G++ optimize("-fcse-follow-jumps")
#pragma G++ optimize("-fsched-interblock")
#pragma G++ optimize("-fpartial-inlining")
#pragma G++ optimize("no-stack-protector")
#pragma G++ optimize("-freorder-functions")
#pragma G++ optimize("-findirect-inlining")
#pragma G++ optimize("-frerun-cse-after-loop")
#pragma G++ optimize("inline-small-functions")
#pragma G++ optimize("-finline-small-functions")
#pragma G++ optimize("-ftree-switch-conversion")
#pragma G++ optimize("-foptimize-sibling-calls")
#pragma G++ optimize("-fexpensive-optimizations")
#pragma G++ optimize("-funsafe-loop-optimizations")
#pragma G++ optimize("inline-functions-called-once")
#pragma G++ optimize("-fdelete-null-pointer-checks")
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define mem(x,y) memset(x,y,sizeof(x))
const int M=2e5+10;
const ll mod=1e9+7;
const int bit=32;
const ll inf=0x3f3f3f3f;
const double pi=acos(-1.0);
ll dp[M][3][2][2];
ll a[M];
int main(){
	int n;
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		scanf("%lld",&a[i]);
	}
	for(int i=0;i<=n;i++){
		for(int j=0;j<3;j++){
			for(int k=0;k<2;k++){
				for(int l=0;l<2;l++)
				dp[i][j][k][l]=-inf*inf;
			}
		}
	}
	if(n==1){
		printf("%lld\n",a[1]);
		return 0;
	}
	dp[1][1][1][0]=a[1];
	dp[1][2][0][0]=-a[1];
	for(int i=1;i<=n;i++){
		for(int j=0;j<=2;j++){
			for(int k=0;k<2;k++){
				for(int l=0;l<2;l++){
					dp[i+1][(j+1)%3][1][l||k==1]=max(dp[i+1][(j+1)%3][1][l||k==1],dp[i][j][k][l]+a[i+1]);
					dp[i+1][(j+2)%3][0][l||k==0]=max(dp[i+1][(j+2)%3][0][l||k==0],dp[i][j][k][l]-a[i+1]);
				}
			}
		}
	}
	printf("%lld\n",max(dp[n][1][1][1],dp[n][1][0][1]));
	return 0;
}