func_code_string: #include <bits/stdc++.h>   using namespace std;   const double PI = acos(-1.0);   double fRand(double fMin, double fMax) {     double f = (double)rand() / RAND_MAX;     return fMin + f * (fMax - fMin);   }   template <class T>   T min(T a, T b, T c) {     return min(a, min(b, c));   }   template <class T>   T max(T a, T b, T c) {     return max(a, max(b, c));   }   long long power(long long x, int n) {     if (n == 0) return 1;     if (n & 1) return (x * power(x, n - 1)) % 1000000007;     long long p = power(x, n / 2);     return (p * p) % 1000000007;   }   int n, a[1000005];   long long fact[1000005], invFact[1000005];   long long C(long long n, long long k) {     return ((fact[n] * invFact[k] % 1000000007) * invFact[n - k]) % 1000000007;   }   int main() {     scanf( %d , &n);     for (int u = (1); u <= (n); ++u) scanf( %d , &a[u]);     fact[0] = invFact[0] = 1;     for (int i = (1); i <= (1000005 - 1); ++i)       fact[i] = (fact[i - 1] * i) % 1000000007;     invFact[1000005 - 1] = power(fact[1000005 - 1], 1000000007 - 2);     for (int i = (1000005 - 2); i >= (1); --i)       invFact[i] = (invFact[i + 1] * (i + 1)) % 1000000007;     sort(a + 1, a + n + 1);     int j = n, ans = 0;     for (int i = (n); i >= (1); --i) {       while (j > 0 && a[j] >= a[i]) --j;       if (a[i] != a[n]) {         int k = n - j - 1;         long long x =             ((C(n, k + 1) * fact[k]) % 1000000007 * fact[n - k - 1]) % 1000000007;         ans = (ans + a[i] * x) % 1000000007;       }     }     printf( %d , ans);     return 0;   }   