#include <bits/stdc++.h>
using namespace std;

long long calc_dist(int N,vector<long long> x(N),vector<long long> order(N)) {
  long long ans = 0;
  for (int i = 0;i<N-1;i++) {
    ans += x.at(i+1)-x.at(i);
    x.at(i) = x.at(i+1);
  }
  return ans;
}

int main() {
  int N;
  vector<long long> x(N);
  for (int i = 0;i < N; i++) {
    cin >> x.at(i);
  }
  
  vector<long long> order(N);
  for (int i = 0; i< N;i++) {
    order.at(0) = i+1;
  }
  
  long long sum = 0;
  
  do {
    sum += calc_dist(N,x,order);
  } while (next_permutation(x.begin(),x.end()));
  
  long long frac = 1;
  for (int i = 1;i<N;i++) {
    frac *= i;
  }
  
  cout << (frac*sum)/(1000000000+7) << endl;
}