#include <bits/stdc++.h>
long long int fact(int n) {
  if (n == 0) {
    return 1;
  } else {
    return n * fact(n - 1);
  }
}
long long int sigma(long long int arr[], int k, int n) {
  int i;
  long long int sum = 0;
  for (i = 0; i <= k; i++) {
    sum += arr[n - 1] - arr[i];
  }
  return sum;
}
int main(void) {
  int n;
  scanf("%d", &n);
  long long int x[n];
  long long int sum[n];
  long long int sos = 0;
  int i, j;
  for (i = 0; i < n; i++) {
    scanf("%lld", &x[i]);
  }
  sum[0] = x[n - 1] - x[0];
  for (i = 1; i < n - 1; i++) {
    sum[i] = sigma(x, i, n);
    printf("sum[%d]=%lld\n", i, sum[i]);
    sos += sum[i] % 1000000007;
    printf("sos=%lld\n", sos);
  }
  printf("sum[0]=%d\n", sum[0]);
  sos += sum[0];
  long long int ans = (sos) % (1000000007);
  printf("fact=%d\n", fact(n - 2));
  printf("%lld", ans);
  return 0;
}
