#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using graph = std::vector<std::vector<long long>>;
int main() {
  ll N;
  cin >> N;
  ll p[N];
  for (ll i = 0; i < N; i++) {
    cin >> p[i];
  }
  ll diff[N - 1];
  for (ll i = 0; i < N - 1; i++) {
    diff[i] = p[i + 1] - p[i];
  }
  ll sum = 0;
  ll MOD = 1000000007ll;
  ll tot[N];
  tot[0] = p[0];
  for (ll i = 1; i < N; i++) {
    tot[i] = (tot[i - 1] + p[i]) % MOD;
  }
  for (ll i = 0; i < N - 1; i++) {
    if (i == 0) {
      sum = p[N - 1] - p[N - 2];
    } else {
      sum = (sum * (ll)(i + 1) % MOD);
      sum = (sum + (tot[N - 1] + MOD - tot[N - 2 - i])) % MOD -
            (p[N - 2 - i] * (ll)(i + 1)) % MOD;
    }
  }
  cout << sum << endl;
}
