#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1e9 + 7;
vector<vector<long long>> combi(int n, long long MOD) {
  long long data[n + 1][n + 1];
  data[0][0] = 1;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < i + 2; j++) {
      if (j == 0)
        data[i + 1][j] = data[i][j];
      else if (j == i + 1)
        data[i + 1][j] = data[i][j - 1];
      else
        data[i + 1][j] = data[i][j - 1] + data[i][j];
      data[i + 1][j] %= MOD;
    }
  }
  vector<vector<long long>> ret;
  for (int i = 0; i < n + 1; i++) {
    ret.push_back({});
    for (int j = 0; j < n + 1; j++) {
      ret[i].push_back(data[i][j]);
    }
  }
  return ret;
}
int main() {
  int n;
  cin >> n;
  long long x[n];
  for (int i = 0; i < n; i++) cin >> x[i];
  long long ans = 0;
  vector<vector<long long>> com = combi(n, MOD);
  long long kaiz[n];
  kaiz[0] = 1;
  for (int i = 0; i < n; i++) {
    long long k = i + 1;
    kaiz[i + 1] = kaiz[i] * k;
    kaiz[i + 1] %= MOD;
  }
  for (int i = 0; i < n - 1; i++) {
    for (int j = i + 1; j < n; j++) {
      long long tmp;
      if (j != n - 1)
        tmp = com[n - 1][j - i + 1] * (x[j] - x[i]);
      else
        tmp = com[n - 1][j - i] * (x[j] - x[i]);
      tmp %= MOD;
      tmp *= kaiz[j - i - 1];
      tmp %= MOD;
      if (j != n - 1)
        tmp *= kaiz[n + i - j - 2];
      else
        tmp *= kaiz[n + i - j - 1];
      tmp %= MOD;
      ans += tmp;
      ans %= MOD;
    }
  }
  cout << ans << endl;
}
