using System; using static System.Console; using System.Linq; using System.Collections.Generic; class Program { static int NN => int.Parse(ReadLine()); static int[] NList => ReadLine().Split().Select(int.Parse).ToArray(); public static void Main() { Solve(); } static void Solve() { var n = NN; var a = NList; Array.Sort(a); var lla = 0L; var llb = 0L; for (var i = n - 1; i >= 0; --i) { if ((n - i) % 2 == 1) lla += a[i]; else llb += a[i]; } var lsa = 0L; var lsb = 0L; for (var i = n / 2; i < n; ++i) lsa += a[i]; for (var i = 0; i < n / 2; ++i) lsb += a[i]; var sla = 0L; var slb = 0L; for (var i = 0; i < n - n / 2; ++i) sla += a[i]; for (var i = n - n / 2; i < n; ++i) slb += a[i]; var ssa = 0L; var ssb = 0L; for (var i = 0; i < n; ++i) { if (i % 2 == 0) ssa += a[i]; else ssb += a[i]; } WriteLine(Math.Max(Math.Min(Math.Abs(lla) - Math.Abs(llb), Math.Abs(lsa) - Math.Abs(lsb)), Math.Min(Math.Abs(sla) - Math.Abs(slb), Math.Abs(ssa) - Math.Abs(ssb)))); } }