#include <bits/stdc++.h>
using namespace std;
void yes() { cout << "Yay!" << endl; }
void no() { cout << ":(" << endl; }
template <class T>
inline void chmax(T& a, T b) {
  a = std::max(a, b);
}
template <class T>
inline void chmin(T& a, T b) {
  a = std::min(a, b);
}
bool prime(long long n) {
  long long cnt = 0;
  for (long long i = 1; i <= sqrt(n); i++) {
    if (n % i == 0) cnt++;
  }
  if (cnt != 1)
    return false;
  else
    return n != 1;
}
long long gcd(long long x, long long y) {
  if (y == 0) return x;
  return gcd(y, x % y);
}
long long lcm(long long x, long long y) { return x / gcd(x, y) * y; }
long long kai(long long x, long long y) {
  long long res = 1;
  for (long long i = x - y + 1; i <= x; i++) {
    res *= i;
    res %= 1000000007;
  }
  return res;
}
long long mod_pow(long long x, long long y, long long m) {
  long long res = 1;
  while (y) {
    if (y & 1) {
      res = res * x % m;
    }
    x = x * x % m;
    y >>= 1;
  }
  return res;
}
long long comb(long long x, long long y) {
  if (y > x) return 0;
  return kai(x, y) * mod_pow(kai(y, y), 1000000007 - 2, 1000000007) %
         1000000007;
}
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
struct edge {
  long long to, cost;
};
long long par[114514], rrank[114514];
void init(long long n) {
  for (long long i = 0; i < n; i++) {
    par[i] = i;
    rrank[i] = 0;
  }
}
long long find(long long x) {
  if (par[x] == x) {
    return x;
  } else
    return par[x] = find(par[x]);
}
void unite(long long x, long long y) {
  x = find(x);
  y = find(y);
  if (x == y) return;
  if (rrank[x] < rrank[y]) {
    par[x] = y;
  } else {
    par[y] = x;
    if (rrank[x] == rrank[y]) rrank[x]++;
  }
}
bool same(long long x, long long y) { return find(x) == find(y); }
long long n;
long long a[2222];
long long memo[2222][2222];
long long x[2222];
long long an[2222];
signed main() {
  cin >> n;
  for (long long i = 0; i < n; i++) cin >> a[i];
  x[0] = 1;
  for (long long i = 1; i <= n; i++) x[i] = x[i - 1] * i;
  for (long long i = 0; i < n - 1; i++) memo[i][i] = x[i];
  for (long long i = 1; i <= n - 2; i++) {
    for (long long j = i - 1; j >= 0; j--) {
      if (memo[i][j] == 0) {
        memo[i][j] = memo[i - 1][j] + memo[i][j + 1];
        memo[i][j] %= 1000000007;
      }
    }
  }
  long long ans = 0, p = 0;
  for (long long i = 0; i < n - 1; i++) {
    ans += (memo[n - 2][i] * a[i]) % 1000000007;
    p += memo[n - 2][i];
    ans %= 1000000007;
    p %= 1000000007;
  }
  p = (p * a[n - 1]);
  cout << (p - ans) % 1000000007 << endl;
  getchar();
  getchar();
  return 0;
}
