#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int mod = 1e9 + 7;
const int inf = (1 << 30) - 1;
const ll infll = (1LL << 61) - 1;
int N;
ll ans;
ll memo[100001];
int main() {
  cin >> N;
  vector<ll> a(N);
  for (int i = 0; i < N; i++) {
    cin >> a[i];
  }
  memo[1] = 1, memo[0] = 0;
  for (ll i = 2; i < 100001; i++) {
    memo[i] = memo[i - 1] * i;
    memo[i] %= mod;
  }
  ll sum = N - 1;
  for (ll i = 0; i < N - 1; i++) {
    ans += (a[i + 1] - a[i]) * sum;
    ans %= mod;
    sum += N - i - 2;
    sum %= mod;
  }
  cout << ans % mod << endl;
}
