{-# LANGUAGE DataKinds #-}
{-# LANGUAGE TypeOperators #-}
{-# LANGUAGE KindSignatures #-}
{-# LANGUAGE ScopedTypeVariables #-}

import GHC.TypeLits
import Data.Int
import Data.Proxy
import qualified Data.Map.Lazy as Map
import Control.Monad
import Control.Monad.State
import Data.List

import Data.Maybe
import qualified Data.ByteString.Char8 as BS


getInts = map (fst . fromJust . BS.readInt) . BS.words <$> BS.getLine


{-- Mod Int --}
data Mint (m :: Nat) = Mint {getMintValue :: Integer} deriving (Eq, Show)

getMintMod :: forall p. KnownNat p => Mint p -> Integer
getMintMod = natVal

makeMint :: forall p. KnownNat p => Integer -> Mint p
makeMint a = let r = Mint $ fromInteger $ a `mod` (getMintMod r) in r

instance KnownNat p => Num (Mint p) where
  (Mint a) + (Mint b) = makeMint $ a + b
  (Mint a) - (Mint b) = makeMint $ a - b
  (Mint a) * (Mint b) = makeMint $ a * b
  negate (Mint a) = makeMint $ negate a
  abs = id
  signum (Mint a) = if a == 0 then 0 else 1
  fromInteger = makeMint

invMint :: forall p. KnownNat p => Mint p -> Mint p
invMint m = let p = getMintMod m in m ^ (p - 2)

powerMint :: forall p. KnownNat p => Integer -> Integer -> Mint p
powerMint n p
  | p >= 0 = (fromInteger n :: Mint p) ^ p
  | otherwise = invMint $ powerMint n (-p)


type M = Mint 1000000007




main :: IO ()
main = do
  n <- readLn :: IO Int
  c <- sort <$> getInts :: IO [Int]

  print $ getMintValue $ sum [(powerMint 2 (fromIntegral $ i-2) :: M) *
                              (fromIntegral $ i+1) *
                               (fromIntegral $ c!!(fromIntegral $ n-i)) *
                               (powerMint 2 (fromIntegral $ n-i) :: M) *
                               (powerMint 2 (fromIntegral n) :: M)
                             | i <- [1..n]]

  return ()
