from collections import deque n = int(input()) c = sorted(map(int, input().split())) s = sum(c) # b_init = s q = deque(c) a = 0 b = s while q: v = 2 * q.popleft() a += v b -= v if q: q.popleft() ans = abs(a) - abs(b) q = deque(c) a = 0 b = s while q: v = 2 * q.pop() a += v b -= v if q: q.pop() ans = max(ans, abs(a) - abs(b)) print(ans)