#include <bits/stdc++.h>
using namespace std;
const int MAX = 510000;
long long fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for (int i = 2; i < MAX; i++) {
    fac[i] = fac[i - 1] * i % (1000000000 + 7);
    inv[i] = (1000000000 + 7) - inv[(1000000000 + 7) % i] *
                                    ((1000000000 + 7) / i) % (1000000000 + 7);
    finv[i] = finv[i - 1] * inv[i] % (1000000000 + 7);
  }
}
long long COM(int n, int k) {
  if (n < k) return 0;
  if (n < 0 || k < 0) return 0;
  return fac[n] * (finv[k] * finv[n - k] % (1000000000 + 7)) % (1000000000 + 7);
}
long long N;
long long jj = 0;
vector<long long> x(2001);
long long ser(vector<long long> a, long long nowN, long long ss) {
  if (nowN == 1) {
    jj += ss;
    jj %= (1000000000 + 7);
    return 0;
  }
  for (long long i = 0; i < nowN - 1; i++) {
    vector<long long> t = a;
    long long c = t[i + 1] - t[i];
    t.erase(t.begin() + i);
    ser(t, nowN - 1, (ss + c) % (1000000000 + 7));
  }
  return 0;
}
int main() {
  cin >> N;
  for (long long i = 0; i < N; i++) {
    cin >> x[i];
  }
  vector<bool> tt(N, 1);
  ;
  ser(x, N, 0);
  cout << jj << endl;
  return 0;
}
