object Main extends App {
  val n = readInt
  val ints = (1 to n).map(_ => readInt).map(_.toLong)
  lazy val (smallerInts, largerInts) = ints.sorted.splitAt(ints.length / 2)
  lazy val (largerInts2, smallerInts2) = ints.sorted.reverse.splitAt(ints.length / 2)
  val res = if (ints.length % 2 == 0) {
    largerInts.head - smallerInts.last - smallerInts.init.sum * 2 + largerInts.tail.sum * 2
  } else {
    val res1 = largerInts.head + largerInts.tail.head + largerInts.tail.tail.sum * 2 - smallerInts.sum * 2
    val res2 = - smallerInts2.head - smallerInts2.tail.head + largerInts2.sum * 2 - smallerInts2.tail.tail.sum * 2
    math.max(res1, res2)
  }
  println(res)
}
