#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll mod = 1e9 + 7;
const ll MAX = 3e3;
ll fac[MAX], finv[MAX], inv[MAX];
ll ans = 0;
void COMinit() {
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for (int i = 2; i < MAX; i++) {
    fac[i] = fac[i - 1] * (ll)i % mod;
    inv[i] = mod - inv[mod % i] * (mod / (ll)i) % mod;
    finv[i] = finv[i - 1] * inv[i] % mod;
  }
}
ll COM(int n, int k) {
  if (n < k) return 0;
  if (n < 0 || k < 0) return 0;
  return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
}
vector<ll> x;
vector<vector<ll>> dp;
ll f(int l, int r) {
  if (dp[l][r] >= 0) return dp[l][r];
  ll res = 0;
  for (int s = l; s < r; s++) {
    ll c = (f(l, s) + f(s + 1, r) + x[r] - x[s]) % mod;
    (res += c * COM(r - l - 1, s - l)) %= mod;
  }
  return dp[l][r] = res;
}
int main() {
  int n;
  cin >> n;
  COMinit();
  x = vector<ll>(n, 0);
  dp = vector<vector<ll>>(n, vector<ll>(n, -1));
  for (int i = 0; i < (int)n; i++) cin >> x[i];
  cout << f(0, n - 1) << endl;
  cout << dp[0][2] << endl;
  return 0;
}
