object Main extends App {
  val n = readInt
  val ints = (1 to n).map(_ => readInt)
  val (smallerInts, largerInts) = ints.sorted.splitAt(ints.length / 2)
  println(largerInts.head - smallerInts.last - smallerInts.init.sum * 2 + largerInts.tail.sum * 2)
}