#include <bits/stdc++.h>
using namespace std;
long long MOD = 1000000007;
long long power(long long a, long long pow) {
  if (pow == 0) {
    return 1;
  }
  auto foo = power(a, pow / 2);
  if (pow % 2 == 0) return (foo * foo) % MOD;
  return (((foo * foo) % MOD) * a) % MOD;
}
long long inv(long long a) { return power(a, MOD - 2); }
int main() {
  long long ans = 0;
  int N;
  cin >> N;
  long long N_contrib = 0;
  for (int i = 1; i < N; i++) {
    N_contrib += inv(i);
    N_contrib %= MOD;
  }
  vector<long long> weights(N + 1);
  for (int i = 0; i <= N; i++) {
    weights[i] = inv(i + 1) * inv(i + 2);
    weights[i] %= MOD;
  }
  vector<long long> weightscs(N + 1);
  weightscs[0] = weights[0];
  for (int i = 1; i <= N; i++) {
    weightscs[i] = weights[i] + weightscs[i - 1];
  }
  vector<long long> X(N + 1);
  for (int i = 1; i <= N; i++) {
    cin >> X[i];
  }
  ans += N_contrib * X[N];
  for (int i = 2; i < N; i++) {
    ans += X[i] * weightscs[i - 2];
    ans %= MOD;
  }
  for (int i = 1; i < N; i++) {
    ans -= X[i];
    ans += MOD;
    ans %= MOD;
  }
  for (int i = 1; i <= N - 1; i++) {
    ans *= i;
    ans %= MOD;
  }
  cout << ans << endl;
}
