#include <bits/stdc++.h>   using namespace std;   const long long mod = 1e9 + 7, inf = 1e17, N = 1e6 + 10;   bool vowel(char che) {     if (che ==  A  || che ==  E  || che ==  I  || che ==  O  || che ==  U  ||         che ==  Y ) {       return true;     } else {       return false;     }   }   long long pw(long long a, long long b) {     long long ans = 1;     while (b) {       if (b % 2 == 1) {         ans = 1ll * ans * a;         ans %= mod;       }       b /= 2;       a = 1ll * a * a % mod;       a %= mod;     }     return ans % mod;   }   bool mark[N], ok[N], h;   char o;   pair<long long, long long> p;   vector<long long> vt[N], vec, jav, vs;   string s, s1;   int64_t a[N], b[N], c[N], d, dp, t, n, m, k, f, ans1, sum, ps;   int64_t fuc[N];   int64_t ans;   int main() {     ios::sync_with_stdio(false);     cin.tie(0);     cout.tie();     cin >> n;     for (int i = 0; i < n; i++) {       cin >> a[i];       a[i] %= mod;     }     fuc[0] = 1;     for (int i = 1; i <= n; i++) {       fuc[i] = 1ll * fuc[i - 1] * i;       fuc[i] %= mod;     }     sort(a, a + n);     f = 1;     a[n] = -25;     ans = 0;     for (int i = 1; i <= n; i++) {       if (a[i] == a[i - 1])         f++;       else {         if (i != n) {           f %= mod;           k = fuc[n] * pw((n - i + f), mod - 2);           k %= mod;           k *= f;           k %= mod;           ans += 1ll * k * a[i - 1];         }         ans %= mod;         f = 1;       }     }     cout << (ans + mod) % mod << endl;   }   