#include <bits/stdc++.h>
using namespace std;
int64_t modi(int64_t n) {
  const int64_t mod = 1000000007;
  if (n >= mod) {
    cout << 0 << endl;
    return 0;
  }
  int64_t ume[11] = {1,         927880474, 933245637, 668123525,
                     429277690, 733333339, 724464507, 957939114,
                     203191898, 586445753, 698611116};
  int64_t x = 100000000;
  int64_t ans = ume[n / x];
  for (int64_t i = n / x * x + 1; i <= n; i++) {
    ans *= i;
    ans %= mod;
  }
  return ans;
}
int main() {
  int64_t N, ans = 0, t;
  long double A = 0, B = 0;
  cin >> N;
  vector<int64_t> x(N);
  for (int i = 0; i < N; i++) {
    cin >> x.at(i);
    if (i != N - 1) {
      A += x.at(i) / (i + 1);
    }
  }
  int64_t sum = 0;
  for (int i = 0; i < N - 1; i++) {
    int64_t sum1 = 1;
    for (int j = 0; j < N - 1; j++) {
      if (j != i) {
        sum1 = sum1 * (j + 1) % 1000000007;
      }
    }
    sum = (sum + sum1) % 1000000007;
  }
  t = modi(N - 1);
  ans = sum * x.at(N - 1) % 1000000007;
  t *= A;
  t %= 1000000007;
  ans -= t;
  if (ans < 0) {
    ans += 1000000007;
  }
  cout << ans << endl;
}
