import java.io.BufferedReader; import java.io.InputStreamReader; import java.util.Arrays; public class Main { public static void main(String[] args) throws Exception { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); int n = Integer.parseInt(br.readLine()); String[] sa = br.readLine().split(" "); int[] c = new int[n]; for (int i = 0; i < n; i++) { c[i] = Integer.parseInt(sa[i]); } br.close(); Arrays.sort(c); long ans1 = calc(c); reverse(c); long ans2 = calc(c); System.out.println(Math.max(ans1, ans2)); } static long calc(int[] c) { int n = c.length; long suma = 0; long sumb = 0; for (int i = 0; i < n; i++) { if (i % 2 == 0) { suma += c[i]; } else { sumb += c[i]; } } long val1 = Math.abs(suma) - Math.abs(sumb); int n2 = (n + 1) / 2; suma = 0; sumb = 0; for (int i = 0; i < n2; i++) { suma += c[i]; } for (int i = n2; i < n; i++) { sumb += c[i]; } long val2 = Math.abs(suma) - Math.abs(sumb); return Math.min(val1, val2); } static void reverse(int[] a) { for (int i = 0; i < a.length / 2; i++) { int tmp = a[i]; a[i] = a[a.length - 1 - i]; a[a.length - 1 - i] = tmp; } } }