func_code_string: #include <bits/stdc++.h>   using namespace std;   using VI = vector<int>;   using VVI = vector<VI>;   using VB = vector<bool>;   using VVB = vector<VB>;   using VD = vector<double>;   using VVD = vector<VD>;   using VS = vector<string>;   using PII = pair<int, int>;   using VPII = vector<PII>;   using VL = vector<long long>;   using VVL = vector<VL>;   int n;   const int MOD = (int)1e9 + 7;   const int MAXN = 300010;   VI A;   int add(int a, int b) {     a = ((a % MOD) + (b % MOD));     return (a >= MOD) ? (a - MOD) : a;   }   int sub(int a, int b) {     a -= b;     return (a < 0) ? (a + MOD) : a;   }   int mul(int a, int b) { return ((long long)a * b) % MOD; }   int powTable[MAXN];   long long sumMaxDistSubsets() {     sort(A.begin(), A.end());     powTable[0] = 1;     for (int i = 1; i <= n; ++i) powTable[i] = (powTable[i - 1] * 2ll) % MOD;     int ret = 0;     for (int i = 1; i <= n; ++i) {       int times = powTable[i - 1] - powTable[n - i];       ret = add(ret, mul(A[i], times));     }     return ret;   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     cin >> n;     A.assign(n + 1, 0);     for (int i = 1; i < (int)n + 1; ++i) cin >> A[i];     cout << sumMaxDistSubsets() << endl;     return 0;   }   