#include <bits/stdc++.h>
using namespace std;
constexpr int MOD = 1e9 + 7;
int n;
int board[1000000];
int l[1000000];
long long fact[1000000];
long long rfact[1000001];
int main(void) {
  scanf("%d", &n);
  for (int i = 0; i < n; i++) scanf("%d", &board[i]);
  sort(board, board + n);
  l[0] = 0;
  for (int i = 1; i < n; i++) {
    if (board[i] == board[i - 1])
      l[i] = l[i - 1];
    else
      l[i] = i;
  }
  fact[0] = 1;
  for (int i = 1; i < n; i++) fact[i] = (fact[i - 1] * (i + 1)) % MOD;
  rfact[n - 1] = n;
  for (int i = n - 2; i >= 0; i--) rfact[i] = (rfact[i + 1] * (i + 1)) % MOD;
  rfact[n] = 1;
  long long result = 0;
  for (int i = 0; board[i] != board[n - 1]; i++) {
    result = (result +
              ((board[i] * fact[n - l[i] - 2]) % MOD * rfact[n - l[i]]) % MOD) %
             MOD;
  }
  printf("%lld\n", result);
  return 0;
}
