#include <bits/stdc++.h>
using namespace std;
int dy[8] = {-1, 0, 1, 0, -1, 1, 1, -1};
int dx[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const int mod = 1000000007;
const int d5 = 100100;
template <int mod>
struct ModInt {
  int x;
  ModInt() : x(0) {}
  ModInt(long long y) : x(y >= 0 ? y % mod : (mod - (-y) % mod) % mod) {}
  ModInt &operator+=(const ModInt &p) {
    if ((x += p.x) >= mod) x -= mod;
    return *this;
  }
  ModInt &operator-=(const ModInt &p) {
    if ((x += mod - p.x) >= mod) x -= mod;
    return *this;
  }
  ModInt &operator*=(const ModInt &p) {
    x = (int)(1LL * x * p.x % mod);
    return *this;
  }
  ModInt &operator/=(const ModInt &p) {
    *this *= p.inverse();
    return *this;
  }
  ModInt operator-() const { return ModInt(-x); }
  ModInt operator+(const ModInt &p) const { return ModInt(*this) += p; }
  ModInt operator-(const ModInt &p) const { return ModInt(*this) -= p; }
  ModInt operator*(const ModInt &p) const { return ModInt(*this) *= p; }
  ModInt operator/(const ModInt &p) const { return ModInt(*this) /= p; }
  bool operator==(const ModInt &p) const { return x == p.x; }
  bool operator!=(const ModInt &p) const { return x != p.x; }
  ModInt inverse() const {
    int a = x, b = mod, u = 1, v = 0, t;
    while (b > 0) {
      t = a / b;
      a -= t * b;
      swap(a, b);
      u -= t * v;
      swap(u, v);
    }
    return ModInt(u);
  }
  ModInt pow(int e) {
    long long a = 1, p = x;
    while (e > 0) {
      if (e % 2 == 0) {
        p = (p * p) % mod;
        e /= 2;
      } else {
        a = (a * p) % mod;
        e--;
      }
    }
    return ModInt(a);
  }
  friend ostream &operator<<(ostream &os, const ModInt<mod> &p) {
    return os << p.x;
  }
  friend istream &operator>>(istream &is, ModInt<mod> &a) {
    long long x;
    is >> x;
    a = ModInt<mod>(x);
    return (is);
  }
};
using modint = ModInt<mod>;
modint f[d5];
void makef() {
  f[0] = 1;
  for (int i = 1; i < d5; i++) f[i] = f[i - 1] * i;
}
modint nCr(int n, int r) {
  if (n < r || r < 0) return 0;
  return f[n] / (f[r] * f[n - r]);
}
signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  makef();
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  modint ta[2020], su[2020];
  for (int i = 0; i < 2020; i++) ta[i] = 0;
  ta[3] = 1;
  su[0] = 0;
  for (int i = 1; i < 2020; i++) su[i] = su[i - 1] + i;
  for (int i = 4; i < 2020; i++) {
    ta[i] = ta[i - 1] * (i - 1);
  }
  modint num[2010][2010];
  for (int i = 0; i < 2010; i++) {
    for (int j = 0; j < 2010; j++) {
      num[i][j] = 0;
    }
  }
  num[1][0] = ta[n];
  for (int i = 1; i < n - 2; i++) {
    num[1 + i][0] = num[1][0] / su[(i + 1)];
  }
  num[n - 1][0] = num[n - 2][0] * (n - 2);
  for (int i = 1; i < n - 2; i++) {
    for (int j = 1; j < n; j++) {
      num[1 + i][j] = num[i][j - 1];
    }
  }
  for (int j = 1; j < n - 1; j++) {
    num[n - 1][j] = num[n - 1][j - 1] + num[n - 2][j - 1];
  }
  modint diff[2010][2010];
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      diff[i][j] = abs(a[i] - a[j]);
    }
  }
  modint res = 0;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      res += diff[i][j] * num[i][j];
    }
  }
  cout << res << endl;
}
