#include <bits/stdc++.h>
using namespace std;

template <typename T>
T pow(T a, long long n, T e = 1) {
    T ret = e;
    while (n) {
        if (n & 1) ret *= a;
        a *= a;
        n >>= 1;
    }
    return ret;
}

template <int mod>
struct ModInt {
    int x;
    ModInt() : x(0) {}
    ModInt(long long x_) {
        if ((x = x_ % mod + mod) >= mod) x -= mod;
    }
    ModInt& operator+=(ModInt rhs) {
        if ((x += rhs.x) >= mod) x -= mod;
        return *this;
    }
    ModInt& operator-=(ModInt rhs) {
        if ((x -= rhs.x) < 0) x += mod;
        return *this;
    }
    ModInt& operator*=(ModInt rhs) {
        x = (unsigned long long)x * rhs.x % mod;
        return *this;
    }
    ModInt& operator/=(ModInt rhs) {
        x = (unsigned long long)x * rhs.inv().x % mod;
        return *this;
    }

    ModInt operator-() const { return -x < 0 ? mod - x : -x; }
    ModInt operator+(ModInt rhs) const { return ModInt(*this) += rhs; }
    ModInt operator-(ModInt rhs) const { return ModInt(*this) -= rhs; }
    ModInt operator*(ModInt rhs) const { return ModInt(*this) *= rhs; }
    ModInt operator/(ModInt rhs) const { return ModInt(*this) /= rhs; }
    bool operator==(ModInt rhs) const { return x == rhs.x; }
    bool operator!=(ModInt rhs) const { return x != rhs.x; }
    ModInt inv() const { return pow(*this, mod - 2); }

    friend ostream& operator<<(ostream& s, ModInt<mod> a) {
        s << a.x;
        return s;
    }
    friend istream& operator>>(istream& s, ModInt<mod>& a) {
        s >> a.x;
        return s;
    }
};

using mint = ModInt<1000000007>;

constexpr int MAX_FACTORIAL = 202020;

mint fact[MAX_FACTORIAL];
mint factinv[MAX_FACTORIAL];

void init() {
    fact[0] = 1;
    for (int i = 1; i < MAX_FACTORIAL; i++) {
        fact[i] = fact[i - 1] * i;
    }
    factinv[MAX_FACTORIAL - 1] = fact[MAX_FACTORIAL - 1].inv();
    for (int i = MAX_FACTORIAL - 2; i >= 0; i--) {
        factinv[i] = factinv[i + 1] * (i + 1);
    }
    assert(factinv[0] == 1);
}

mint ncr(int n, int r) { return fact[n] * factinv[r] * factinv[n - r]; }

template <typename T>
struct BIT {
    int n;
    vector<T> data;

    BIT(int n) : n(n), data(n + 1) {}
    void add(int a, T w) {
        for (int x = ++a; x <= n; x += x & -x) data[x] += w;
    }
    // [0, a)
    T sum(int a) {
        T ret = 0;
        for (int x = a; x > 0; x -= x & -x) ret += data[x];
        return ret;
    }
};

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    init();

    int n;
    cin >> n;
    vector<int> xs(n);
    for (int i = 0; i < n; i++) cin >> xs[i];

    // mint ans = 0;
    // for (int i = 0; i < n - 1; i++) {
    //     for (int j = i + 1; j < n; j++) {
    //         int dist = xs[j] - xs[i];
    //         int aida = j - i - 1;
    //         if (j == n - 1) {
    //             ans += fact[n - 1] * factinv[1 + aida] * fact[aida] * dist;
    //         } else {
    //             ans += fact[n - 1] * factinv[2 + aida] * fact[aida] * dist;
    //         }
    //     }
    // }

    mint ans = 0;
    for (int i = 0; i < n - 1; i++) {
        int j = n - 1;
        int dist = xs[j] - xs[i];
        int aida = j - i - 1;
        ans += fact[n - 1] * factinv[1 + aida] * fact[aida] * dist;
    }

    BIT<long long> bit(n);
    for (int i = 0; i < n - 1; i++) bit.add(i, xs[i]);

    auto top = [&](int k) { return bit.sum(n - 1) - bit.sum(n - 1 - k); };
    auto bottom = [&](int k) { return bit.sum(k); };

    for (int aida = 0; aida < n - 2; aida++) {
        ans += fact[n - 1] * factinv[2 + aida] * fact[aida] * (top(n - 2 - aida) - bottom(n - 2 - aida));
    }

    cout << ans << endl;
}


Measured memory_bytes: 3072