module.exports=function(r){var e={};function t(n){if(e[n])return e[n].exports;var o=e[n]={i:n,l:!1,exports:{}};return r[n].call(o.exports,o,o.exports,t),o.l=!0,o.exports}return t.m=r,t.c=e,t.d=function(r,e,n){t.o(r,e)||Object.defineProperty(r,e,{enumerable:!0,get:n})},t.r=function(r){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(r,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(r,"__esModule",{value:!0})},t.t=function(r,e){if(1&e&&(r=t(r)),8&e)return r;if(4&e&&"object"==typeof r&&r&&r.__esModule)return r;var n=Object.create(null);if(t.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:r}),2&e&&"string"!=typeof r)for(var o in r)t.d(n,o,function(e){return r[e]}.bind(null,o));return n},t.n=function(r){var e=r&&r.__esModule?function(){return r.default}:function(){return r};return t.d(e,"a",e),e},t.o=function(r,e){return Object.prototype.hasOwnProperty.call(r,e)},t.p="",t(t.s=0)}([function(r,e,t){t(1)(t(2).readFileSync("/dev/stdin","UTF-8").split("\n"))},function(r,e,t){"use strict";r.exports=function(r){for(var e=Number(r[0]),t=[],n=0;n<e;n++)t.push(Number(r[n+1]));t.sort(function(r,e){return r-e});var o=e%2==0?e/2-1:Math.floor(e/2),u=e%2==0?e/2:Math.floor(e/2),f=new Array(e);f[u]=t[0];for(var a=1;a<=o;a++)a%2==0?(f[u-a]=t[a-1],f[u+a]=t[a]):(f[u-a]=t[e-a],f[u+a]=t[e-a-1]);e%2==0&&(f[0]=e/2%2==0?t[o]:t[u]);for(var i=0,l=1;l<e;l++)i+=Math.abs(f[l]-f[l-1]);var c=new Array(e);c[u]=t[e-1];for(var s=1;s<=o;s++)s%2==0?(c[u-s]=t[e-s-1],c[u+s]=t[e-s]):(c[u-s]=t[s],c[u+s]=t[s-1]);e%2==0&&(c[0]=e/2%2==0?t[o]:t[u]);for(var p=0,d=1;d<e;d++)p+=Math.abs(c[d]-c[d-1]);p>i&&(i=p),console.log(i)}},function(r,e){r.exports=require("fs")}]);