Language: C++

#include <bits/stdc++.h>

#define repd(i, a, b) for (ll i = (a); i < (b); i++)
#define repb(i, n) for (ll i = (n)-1; i >= 0; i--)
#define rep(i, n) repd(i, 0, n)

using namespace std;

using ll = long long;
using ul = unsigned long long;
using ld = long double;
const int mod = 1000000007;

ll rep_square(ll a, ll b) {
    // return a^b
    ll ans = 1;
    ll base = a;
    while (b != 0) {
        if (b & 1) {
            ans *= base;
            ans %= mod;
        }
        base *= base;
        base %= mod;
        b >>= 1;
    }
    return ans;
}

template <std::uint_fast64_t Modulus> class modint {
    using u64 = std::uint_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) 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 modint &operator/=(modint rhs) noexcept {
        u64 exp = Modulus - 2;
        while (exp) {
            if (exp % 2) {
                *this *= rhs;
            }
            rhs *= rhs;
            exp /= 2;
        }
        return *this;
    }
    modint pow(modint m) {
        modint ans = 1, base = a;
        while (m.a != 0) {
            if (m.a & 1) {
                ans *= base;
            }
            base *= base;
            m.a /= 2;
        }
        return ans;
    }
};

ll solve(ll n, ll m) { return pow(2, 2 * n - 2) * (2 + m) % mod; }

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n;
    cin >> n;
    vector<ll> a(n);
    rep(i, n) { cin >> a[i]; }

    sort(a.begin(), a.end(), greater<ll>());

    using m = modint<mod>;
    m ans = 0;
    rep(i, n) { ans += m(a[i]) * m(2).pow(2 * n - 2) * m(2 + i); }
    cout << ans.a << endl;
    return 0;
}



Compiler output:
a.cc: In function 'll solve(ll, ll)':
a.cc:93:59: error: invalid operands of types '__gnu_cxx::__promote<double>::__type' {aka 'double'} and 'const int' to binary 'operator%'
   93 | ll solve(ll n, ll m) { return pow(2, 2 * n - 2) * (2 + m) % mod; }
      |                               ~~~~~~~~~~~~~~~~~~~~~~~~~~~ ^ ~~~
      |                                                 |           |
      |                                                 |           const int
      |                                                 __gnu_cxx::__promote<double>::__type {aka double}