func_code_string: #include <bits/stdc++.h>   using namespace std;   const int Mod = 1e9 + 7;   const int N = 1000005;   long long frac[N + 5], inv[N + 5];   int n, a[N], y[N], Max;   long long ans;   inline int read() {     int x = 0, f = 1;     char ch = getchar();     while (ch <  0  || ch >  9 ) {       if (ch ==  - ) f = -1;       ch = getchar();     }     while (ch >=  0  && ch <=  9 ) {       x = (x << 1) + (x << 3) + (ch ^ 48);       ch = getchar();     }     return x * f;   }   long long power(long long a, long long b) {     long long res = 1;     for (; b; b >>= 1) {       if (b & 1) res = res * a % Mod;       a = a * a % Mod;     }     return res;   }   long long C(int m, int n) { return frac[n] * inv[m] % Mod * inv[n - m] % Mod; }   int main() {     n = read();     frac[1] = 1;     frac[0] = 1;     for (int i = 2; i <= n + 2; i++) frac[i] = frac[i - 1] * i % Mod;     inv[n + 2] = power(frac[n + 2], Mod - 2);     for (int i = n + 1; i >= 0; i--) inv[i] = inv[i + 1] * (i + 1) % Mod;     inv[0] = 1;     for (int i = 1; i <= n; i++) a[i] = read();     sort(a + 1, a + n + 1);     a[0] = -1;     for (int i = 1; i <= n; i++) {       Max = max(Max, a[i]);       if (a[i] == a[i - 1]) {         y[i] = y[i - 1];         continue;       }       for (int j = i; j >= 0; j--) {         if (a[j] != a[i]) {           y[i] = n - j;           break;         }       }       --y[i];     }     for (int i = 1; i <= n; i++) {       if (a[i] == Max) continue;       ans = (ans + (a[i] * frac[y[i]] % Mod * frac[n - y[i] - 1] % Mod *                     C(y[i] + 1, n) % Mod)) %             Mod;     }     printf( %lld n , ans);     return 0;   }   