let () = Scanf.scanf "%d\n" @@ fun n ->
  let as_ = Array.init n @@ fun _ -> Scanf.scanf "%d\n" @@ fun a -> a in
  Array.sort compare as_;
  Printf.printf "%d\n" @@
  if n mod 2 = 0
  then
    2 * Array.fold_left ( + ) 0 (Array.sub as_ ((n + 1) / 2) (n / 2))
    - 2 * Array.fold_left ( + ) 0 (Array.sub as_ 0 ((n + 1) / 2))
    - as_.(n / 2)
    + as_.(n / 2 - 1)
  else
    max
      ( 2 * Array.fold_left ( + ) 0 (Array.sub as_ ((n + 1) / 2) (n / 2))
      - 2 * Array.fold_left ( + ) 0 (Array.sub as_ 0 ((n + 1) / 2))
      + as_.(n / 2)
      + as_.(n / 2 - 1) )
      ( 2 * Array.fold_left ( + ) 0 (Array.sub as_ (n / 2) ((n + 1) / 2))
      - 2 * Array.fold_left ( + ) 0 (Array.sub as_ 0 (n / 2))
      - as_.(n / 2)
      - as_.(n / 2 + 1) )
    
