#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

#define repd(i, a, b) for (ll i = (a); i < (b); i++)
#define rep(i, n) repd(i, 0, n)

using namespace std;

namespace mp = boost::multiprecision;

using ll = long long;
using Bint = mp::cpp_int;
ll mod = pow(10, 9) + 7;

Bint fact(Bint n) {
    if (n == 1) {
        return 1;
    }

    return n * fact(n - 1);
}

int main() {
    // source
    ll n;
    cin >> n;

    ll x[n];
    rep(i, n) { cin >> x[i]; }

    if (n == 2) {
        cout << x[1] - x[0] << endl;
        return 0;
    }

    ll x_diff[n - 1];
    rep(i, n - 1) { x_diff[i] = x[i + 1] - x[i]; }

    Bint weight_all = fact(n - 1);
    Bint weight_other = weight_all + (weight_all / 2);

    Bint x_weight[n - 1];

    rep(i, n - 1) { x_weight[i] = weight_other; };
    x_weight[0] = weight_all;
    x_weight[n - 2] = weight_all;

    Bint temp = weight_all / 2;
    while (true) {
        x_weight[n - 2] += temp;
        temp /= 2;
        if (temp == 0) {
            break;
        }
    }
    rep(i, n - 1) { cout << x_weight[i] << " "; }
    cout << endl;

    Bint ans = 0;
    rep(i, n - 1) { ans += x_diff[i] * x_weight[i]; }

    ll ans_out = (ll)(ans % mod);

    cout << ans_out << endl;
    return 0;
}

