#include <bits/stdc++.h>
using namespace std;
long long dp[2005][2005];
long long f[2005];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long n;
  cin >> n;
  long long a[n + 5];
  for (long long i = 1; i <= n; i++) cin >> a[i];
  f[0] = 1;
  for (long long i = 1; i <= 2000; i++) {
    f[i] = i * f[i - 1] + 1;
    f[i] %= 1000000007;
  }
  dp[0][0] = 1;
  dp[1][0] = 3;
  for (long long i = 2; i <= 2000; i++) {
    dp[i][0] = (i + 2) * dp[i - 1][0] - (i - 1) * dp[i - 2][0];
    dp[i][0] %= 1000000007;
  }
  for (long long i = 1; i <= 2000; i++) {
    for (long long j = 1; j <= i; j++) {
      dp[i][j] = dp[i][j - 1] - dp[i - 1][j - 1];
      dp[i][j] %= 1000000007;
    }
  }
  vector<long long> v;
  for (long long i = 1; i < n; i++) {
    v.push_back(a[i + 1] - a[i]);
  }
  long long ans = 0;
  long long pengali[n + 5];
  pengali[0] = f[n - 2];
  for (long long i = 1; i <= n - 1; i++) {
    pengali[i] = pengali[i - 1] + dp[n - 3][i - 1];
    pengali[i] %= 1000000007;
  }
  for (long long i = 0; i < v.size(); i++) {
    cout << v[i] << " " << pengali[i] << endl;
    ans += (v[i] % 1000000007) * (pengali[i] % 1000000007);
    ans %= 1000000007;
  }
  cout << ans % 1000000007 << endl;
  return 0;
}
