module mod_quick_sort
  implicit none
  integer, private, parameter :: intkind = 8
contains
  logical function less(a, b) result(res)
    integer(intkind), intent(in) :: a, b
    res = a >= b
  end
  subroutine swap(a, b)
    integer(intkind), intent(inout) :: a, b
    a = xor(a, b)
    b = xor(a, b)
    a = xor(a, b)
  end
  recursive subroutine quick_sort(a)
    integer(intkind), intent(inout) :: a(:)
    integer(intkind) :: p
    integer :: n, l, r, m
    n = size(a)
    l = 1
    r = n
    m = (n + 1) / 2
    p = a(l) + a(m) + a(r) - min(a(l), a(m), a(r)) - max(a(l), a(m), a(r))
    do
      do while (.not.less(p, a(l)))
        l = l + 1
      end do
      do while (.not.less(a(r), p))
        r = r - 1
      end do
      if (l >= r) exit
      call swap(a(l), a(r))
      l = l + 1
      r = r - 1
    end do
    if (1 < l - 1) call quick_sort(a(1:l - 1))
    if (r + 1 < n) call quick_sort(a(r + 1:n))
  end
end module mod_quick_sort
program change_a_little_bit
  use mod_quick_sort
  implicit none
  integer(8), parameter :: modu = 1000000007
  integer :: n, i
  integer(8) :: c(200000) = 0, x = 0
  read(*,*) n
  read(*,*) c(1:n)
  call quick_sort(c(1:n))
  do i = 1, n
    x = x + mod(c(i) * (i + 1), modu)
  end do
  x = mod(x, modu)
  write(*,'(i0)') mod(pow(4_8, n - 1) * x, modu)
contains
  pure elemental integer(8) function pow(a, n) result(res)
    integer(8), intent(in) :: a
    integer, intent(in) :: n
    integer(8) :: b
    integer :: m
    res = 1
    b = a
    m = n
    do while (m > 0)
      if (btest(m, 0)) res = mod(res * b, modu)
      b = mod(b * b, modu)
      m = rshift(m, 1)
    end do
  end
end program change_a_little_bit