let () =
    let m = 1_000_000_000 + 7 in
    let ( +@ ) a b = (a + b) mod m in
    let ( *@ ) a b = ((a mod m) * (b mod m)) mod m in
    let pow4 b =
        let rec loop a b acc =
            if b = 0 then acc else
                let acc = if b land 1 = 1 then acc *@ a else acc in
                let a = a *@ a in
                loop a (b lsr 1) acc
        in
        loop 4 b 1
    in

    let main () =
        let n = int_of_string (read_line ()) in
        let c = Array.init n (fun _ -> Scanf.scanf " %d" (fun c -> c)) in
        Array.sort compare c;
        let q = pow4 (n - 1) in
        let rec loop i acc =
            if i < 0 then acc else loop (i - 1) (acc +@ q *@ c.(i) *@ (n + 1 - i))
        in
        loop (n - 1) 0 |> Printf.printf "%d\n"
    in
    main ()