M=10**9+7
N=gets.to_i
C=gets.split.map(&:to_i).sort

pow=Array.new(N+1){1}
N.times do |i|
  pow[i+1]=(2*pow[i])%M
end

s=1
(N-1).times do |i|
  s=(2*s+pow[i])%M
end

t=Array.new(N+1){0}
N.times do |i|
  t[i+1]=(2*t[i]+pow[i])%M
end

ans=0
N.times do |i|
  ans+=C[i]*s
  ans-=C[i]*(pow[N-1-i])*(t[i])
  ans%=M
end
ans*=pow[N]
ans%=M
p((ans+M)%M)
