#include <bits/stdc++.h>
using namespace std;
using namespace std;
int main() {
  long long int N;
  scanf("%lld", &N);
  long long int x[N];
  for (long long int i = 0; i < N; i++) {
    scanf("%lld", &x[i]);
  }
  long long int answer = 0;
  long long int np = 1;
  for (long long int i = 1; i < N; i++) {
    answer += np * (x[N - 1] - x[N - i - 1]);
    answer = answer % 1000000007;
    np = np * (N - i);
    np = np % 1000000007;
  }
  printf("%lld", answer);
}
