#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  vector<int> vec;
  cin >> n;
  for (int i = 0; i < n; i++) {
    int num;
    cin >> num;
    vec.push_back(num);
  }
  int matrixOfDis[2005][2005];
  for (int i = 0; i < 2005; i++) {
    for (int j = 0; j < 2005; j++) {
      matrixOfDis[i][j] = 0;
    }
  }
  for (int i = 0; i < n - 1; i++) {
    for (int j = n - 1; j > i; j--) {
      matrixOfDis[i][j] = vec[j] - vec[i];
    }
  }
  int kaijo = n - 1;
  while (kaijo > 0) {
    kaijo = (kaijo * (kaijo - 1)) % 1000000007;
    kaijo--;
  }
  int matrixOfMagic[2005][2005];
  for (int i = 0; i < 2005; i++) {
    for (int j = 0; j < 2005; j++) {
      matrixOfMagic[i][j] = 0;
    }
  }
  matrixOfMagic[n - 2][n - 1] = kaijo;
  for (int i = n - 3; i >= 0; i--) {
    for (int j = n - 1; j > i; j--) {
      if (j == n - 1) {
        matrixOfMagic[i][j] =
            (matrixOfMagic[i + 1][j] * ((n - i - 2) / (n - i - 1))) %
            1000000007;
      } else if (j == n - 2) {
        matrixOfMagic[i][j] =
            matrixOfMagic[i + 1][j + 1] * (1 / (n - i - 1)) % 1000000007;
      } else {
        matrixOfMagic[i + 1][j + 1];
      }
    }
  }
  int sum;
  for (int i = 0; i < 2005; i++) {
    for (int j = 0; j < 2005; j++) {
      sum += (matrixOfMagic[i][j] * matrixOfDis[i][j]) % 1000000007;
    }
  }
  cout << sum;
  return 0;
}
