#include<bits/stdc++.h>

typedef long long ll;
typedef std::pair<ll, ll> P;

constexpr ll INF = 1e15;
constexpr ll mod = 1e9+7;

#define rep(i,n) for(int i = 0; i < int(n); i++)
using namespace std;

template<class T> inline bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }

ll mpow(ll x, ll n) {
    if (n < 0) return 0;
    ll ans = 1; x %= mod;
    while (n != 0) {
        if (n & 1) ans = ans * x % mod;
        x = x * x % mod;
        n = n >> 1;
    }
    return ans;
}

ll inv_mod(ll a) { return mpow(a, mod - 2); }

class Factorial {
private:
    vector<ll> fac;
    vector<ll> ifac;
public:

    Factorial(ll N) {
        fac.push_back(1);
        for (int i = 0; i < N; i++) fac.push_back(fac[i] * (i + 1) % mod);
        ifac.resize(N + 1);
        ifac[N] = inv_mod(fac[N]);
        for (int i = 0; i < N; i++) ifac[N - 1 - i] = (ifac[N - i] * (N - i)) % mod;
    }

    ll fact(ll a) { return fac[a]; }
    ll ifact(ll a) { return ifac[a]; }

    ll cmb(ll a, ll b) {
        if (a == 0 && b == 0) return 1;
        if (a < b || a < 0 || b < 0) return 0;
        ll tmp = ifact(a - b) * ifact(b) % mod;
        return tmp * fac[a] % mod;
    }
    ll per(ll a, ll b) {
        if (a == 0 && b == 0) return 1;
        if (a < b || a < 0 || b < 0) return 0;
        return fac[a] * ifac[a - b] % mod;
    }
};


class modint {
    static constexpr std::int_fast64_t Modulus = 1e9 + 7;
    using u64 = std::int_fast64_t;

public:
    u64 a;
    constexpr modint(const u64 x = 0) noexcept : a(x% Modulus) {}
    constexpr u64& value() noexcept { return a; }
    constexpr const u64& value() const noexcept { return a; }
    constexpr modint operator+(const modint rhs) const noexcept {
        return modint(*this) += rhs;
    }
    constexpr modint operator-(const modint rhs) const noexcept {
        return modint(*this) -= rhs;
    }
    constexpr modint operator*(const modint rhs) const noexcept {
        return modint(*this) *= rhs;
    }
    constexpr modint& operator+=(const modint rhs) noexcept {
        a += rhs.a;
        if (a >= Modulus) {
            a -= Modulus;
        }
        return *this;
    }
    constexpr modint& operator-=(const modint rhs) noexcept {
        if (a < rhs.a) {
            a += Modulus;
        }
        a -= rhs.a;
        return *this;
    }
    constexpr modint& operator*=(const modint rhs) noexcept {
        a = a * rhs.a % Modulus;
        return *this;
    }
    constexpr operator u64() const { return a; }
};

void naive(const vector<ll>& cs) {
    int n = cs.size();
    Factorial f(n);
    modint sum = 0;
    vector<ll> diffs(n, 0);
    for (ll i = 0; i < 1LL << n; i++) {
        for (ll j = 0; j < 1LL << n; j++) {
            for (int k = 0; k < n; k++) {
                if(((i >> k) ^ (j >> k)) & 1) {
                    ll diff = 0;
                    for (int m = k; m < n; m++) {
                        if (((i >> m) ^ (j >> m)) & 1) {
                            diff++;
                        }
                    }
                    diffs[k] += diff;
                    //cout << i << "," << j << "," << k << "," << diff << endl;
                    sum += diff * cs[k];
                }
            }
        }
    }
    for (auto p : diffs) {
        cout << p << ",";
    }
    cout << endl;
    cout << sum << endl;
}

int main() {
    ll n;
    cin >> n;
    vector<ll> cs(n);
    rep(i, n) cin >> cs[i];
    sort(cs.begin(), cs.end());
    
    modint sum = 0;
    //Factorial f(n);
    for (int a = 0; a < n; a++) {
        modint csum = 0;
        ll left = a;
        ll right = n - a;
        //modint all = 0;
        //for (int j = 0; j < right; j++) {
        //    modint c = f.cmb(n - a - 1, j) * (j+1);
        //    all += c;
        //}
        modint all4 = mpow(2, right - 1); // a番目は常に選ばれるので 2^右側
        all4 += mpow(2, right - 2) * modint(right - 1); //a番目以降は 2^(右側-自分)回選ばれ, (right-1)個ある
        //auto all3 = mpow(2, right - 2) + mpow(2, right - 1);
        //cout << a << "," << all << "," << all4 << endl;
        modint all2 = modint(mpow(2, right)) * modint(mpow(4, left)) * all4;
        //cout << a << "," << all << "," << all2 << "," << cs[a] * all2 << endl;
        sum += cs[a] * all2;
    }
    cout << sum.a << endl;
    return 0;
}


Measured memory_bytes: 4772