#include using namespace std; #define N 100005 typedef long long ll; typedef unsigned long long ull; ll n, a[N], s[2], ans; int main() { #ifndef ONLINE_JUDGE freopen("admin.in", "r", stdin); // freopen("admin.out", "w", stdout); #endif scanf("%lld", &n); for (int i = 1; i <= n; i++) scanf("%lld", a + i); sort(a + 1, a + 1 + n); int l, r, now; if (a[1] < 0) { if (a[2] < 0) { s[0] = s[1] = 0; now = 0; for (int i = 1; i <= n; i++, now ^= 1) s[now] += a[i]; ans = max(ans, abs(s[0]) - abs(s[1])); } if (a[n] >= 0) { s[0] = s[1] = 0; l = 1, r = n, now = 0; while (l <= r) { if (now & 1) s[0] += a[l++]; else s[1] += a[r--]; now ^= 1; } ans = max(ans, abs(s[0]) - abs(s[1])); } } if (a[n] >= 0) { if (a[1] < 0) { s[0] = s[1] = 0; l = 1, r = n, now = 0; while (l <= r) { if (now & 1) s[0] += a[r--]; else s[1] += a[l++]; now ^= 1; } ans = max(ans, abs(s[0]) - abs(s[1])); } if (a[n - 1] >= 0) { s[0] = s[1] = 0; now = 0; for (int i = n; i >= 1; i--, now ^= 1) s[now] += a[i]; ans = max(ans, abs(s[0]) - abs(s[1])); } } printf("%lld", ans); return 0; }