#include <bits/stdc++.h>
using namespace std;
int N;
vector<int> X;
long long fact[100001];
void _fact() {
  fact[0] = 1;
  for (int i = 0; i < 100000; i++)
    fact[i] = (fact[i] * fact[i - 1]) % (int(1e9) + 7);
}
long long sigma;
long long form() {
  sigma = (X[N - 1] - X[0]);
  long long ans = fact[N - 1] * sigma;
  for (int i = 2; i < N; i++) {
    for (int j = 1; j < i; j++) {
      ans = (ans + fact[N - 2] * (X[j] - X[i])) % (int(1e9) + 7);
    }
  }
  return ans;
}
int main() {
  cin >> N;
  for (int x, i = 0; i < N; i++) {
    cin >> x;
    X.push_back(x);
  }
  sort(X.begin(), X.end());
  cout << form();
}
