#include <bits/stdc++.h>
using namespace std;
istream& in = cin;
int n;
int a[1000010];
void input() {
  in >> n;
  for (int i = 1; i <= n; ++i) in >> a[i];
}
long long mod = (long long)1e9 + 7;
long long fac[1000010], inv[1000010];
long long quick_mod(long long a, long long p) {
  long long ret = 1;
  a %= mod;
  while (p) {
    if (p & 1) ret = ret * a % mod;
    a = a * a % mod;
    p /= 2;
  }
  return ret;
}
long long C(int n, int m) { return fac[n] * inv[m] % mod * inv[n - m] % mod; }
long long cale(int k) {
  long long large = fac[k];
  long long less = 1;
  less = fac[n] * inv[k + 1] % mod;
  return large * less % mod;
}
int main() {
  fac[0] = 1;
  for (int i = 1; i < 1000010; ++i) fac[i] = fac[i - 1] * i % mod;
  inv[1000009] = quick_mod(fac[1000009], mod - 2);
  for (int i = 1000008; i >= 0; --i) inv[i] = inv[i + 1] * (i + 1) % mod;
  int TEST_CASE = 1;
  while (TEST_CASE-- > 0) {
    input();
    sort(a + 1, a + n + 1);
    long long ans = 0;
    a[0] = -1;
    int pos = 1, K = n;
    while (pos <= n) {
      int val = a[pos];
      int num = 0;
      while (a[pos] == val) {
        pos++;
        num++;
      }
      if (val != a[n]) ans = (ans + cale(K - 1) * num % mod * val % mod) % mod;
      K -= num;
    }
    cout << ans << endl;
  }
  return 0;
}
