#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
  ll N;
  cin >> N;
  vector<ll> X(N);
  for (int i = 0; i < N; i++) {
    cin >> X.at(i);
  }
  ll ans = 0;
  for (int i = 0; i < N; i++) {
    ll count = 0;
    for (int j = 0; j < N; j++) {
      if (i == j) {
      } else {
        count += abs(X.at(j) - X.at(i));
        count %= 1000000007;
      }
      ans += count;
    }
  }
  for (int i = 1; i < N + 1; i++) {
    ans *= i;
    ans %= 1000000007;
  }
  cout << ans << endl;
}
