#include <bits/stdc++.h>
using namespace std;
struct ProconInit {
  static constexpr int IOS_PREC = 15;
  static constexpr bool AUTOFLUSH = false;
  ProconInit() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(IOS_PREC);
    if (AUTOFLUSH) cout << unitbuf;
  }
} PROCON_INIT;
int permutationMethod(int n, int r) {
  r = n - r;
  int sum = 1;
  int i;
  for (i = n; i >= r + 1; i--) sum *= i;
  return sum;
}
const int NM = 10000;
long long X[NM];
long long sel[NM];
long long tmpX[NM];
void solve() {
  long long N;
  cin >> N;
  long long sum = 0;
  long long M = 100000007;
  long long mod = 1;
  for (int i = 1; i <= N; i++) {
    mod = (mod * i) % M;
  }
  for (int i = 0; i < N; i++) {
    cin >> X[i];
    tmpX[i] = X[i];
  }
  vector<int> v(N - 1);
  iota(v.begin(), v.end(), 1);
  do {
    int i = 0;
    for (auto x : v) {
      sel[i] = x - 1;
      i++;
    }
    for (int i = 0; i < N - 1; i++) {
      tmpX[i] = X[i];
    }
    for (int i = 0; i < N - 1; i++) {
      int j = sel[i] + 1;
      while (j != N && tmpX[j] == 0) {
        j++;
      }
      sum += (tmpX[j] - tmpX[sel[i]]) * mod % M;
      tmpX[sel[i] + 1] = tmpX[sel[i]];
      tmpX[sel[i]] = 0;
    }
  } while (next_permutation(v.begin(), v.end()));
  sum /= N;
  cout << sum;
  return;
}
int main() {
  solve();
  return 0;
}
