#include <bits/stdc++.h>
using namespace std;
constexpr long long MOD = 1e9 + 7;
int dx[8] = {1, 0, -1, 0, 1, 1, -1, -1};
int dy[8] = {0, 1, 0, -1, 1, -1, 1, -1};
long long A, B, C, D, E, F, G, H, N, M, L, K, P, Q, R, W, X, Y, Z;
string S, T;
template <typename T>
istream &operator>>(istream &is, vector<T> &vec) {
  for (T &x : vec) is >> x;
  return is;
}
class Fp {
 public:
  long long val;
  static long long mod;
  Fp() { val = 0; }
  Fp(long long v) : val(v % mod) {
    if (val < 0) val += mod;
  }
  Fp operator+=(const Fp &in) {
    val += in.val;
    calc_mod(val);
    return *this;
  }
  Fp operator+(const Fp &in) const { return Fp(*this) += in; }
  Fp &operator-=(const Fp &in) {
    val -= in.val;
    calc_mod(val);
    if (val < 0) val += mod;
    return *this;
  }
  Fp operator-(const Fp &in) const { return Fp(*this) -= in; }
  Fp &operator*=(const Fp &in) {
    val = val * in.val % mod;
    return *this;
  }
  Fp operator*(const Fp &in) const { return Fp(*this) *= in; }
  Fp &operator/=(const Fp &in) {
    *this *= in.modpow(mod - 2);
    return *this;
  }
  Fp operator/(const Fp &in) const { return Fp(*this) /= in; }
  bool operator==(const Fp &in) const { return val == in.val; }
  bool operator!=(const Fp &in) const { return val != in.val; }
  Fp modpow(long long n) const {
    if (n == 0) return 1;
    if (n & 1) {
      return (*this) * ((*this) * (*this)).modpow(n / 2);
    } else {
      return ((*this) * (*this)).modpow(n / 2);
    }
  }
  friend istream &operator>>(istream &is, Fp &fp) {
    is >> fp.val;
    return is;
  }
  friend ostream &operator<<(ostream &os, Fp &fp) {
    os << fp.val;
    return os;
  }
  friend ostream &operator<<(ostream &os, Fp &&fp) {
    os << fp.val;
    return os;
  }

 private:
  void calc_mod(long long &v) {
    if (v >= mod) v -= mod;
  }
};
Fp modpow(const Fp &in, const long long n) { return in.modpow(n); }
Fp modpow(const long long a, const long long n) { return Fp(a).modpow(n); }
using mint = Fp;
long long mint::mod = MOD;
class Factorial {
 public:
  vector<mint> fact, finv;
  Factorial(long long n) : fact(n + 1, mint(1)), finv(n + 1, mint(1)) {
    for (int i = 2; i <= n; i++) {
      mint tmp(i);
      fact[i] = fact[i - 1] * tmp;
      finv[i] = finv[i - 1] / tmp;
    }
  }
  mint com(const long long &n, const long long &k) {
    if (n < k || n < 0 || k < 0) return mint(0);
    return fact[n] * finv[k] * finv[n - k];
  }
};
vector<mint> x;
vector<vector<int>> flag;
vector<vector<mint>> dp;
mint dfs(int p, int q) {
  mint res = 0;
  if (flag[p][q] == 1) {
    return dp[p][q];
  }
  if (p == q) {
    return mint(0);
  }
  for (int i = p; i < q; i++) {
    res += (dfs(p, i) + x[q] - x[i] + dfs(i + 1, q)) / (q - p);
  }
  flag[p][q] = 1;
  return res;
}
signed main() {
  cin >> N;
  vector<mint> y(N);
  cin >> y;
  x = y;
  vector<vector<int>> tmp(N, vector<int>(N));
  vector<vector<mint>> ttmp(N, vector<mint>(N));
  flag = tmp;
  dp = ttmp;
  mint ans = dfs(0, N - 1);
  Factorial f(N - 1);
  ans *= f.fact[N - 1];
  cout << ans << "\n";
}
