#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <algorithm>
using namespace std;
#define re(i, n) for (int i=0; i<n; i++)
#define re1(i, n) for (int i=1; i<=n; i++)
#define re2(i, l, r) for (int i=l; i<r; i++)
#define re3(i, l, r) for (int i=l; i<=r; i++)
#define rre(i, n) for (int i=n-1; i>=0; i--)
#define rre1(i, n) for (int i=n; i>0; i--)
#define rre2(i, r, l) for (int i=r-1; i>=l; i--)
#define rre3(i, r, l) for (int i=r; i>=l; i--)
#define ll long long
const int MAXN = 100010, INF = ~0U >> 2;
struct sss {
int v, No;
bool operator< (sss s0) const {return v < s0.v;}
} A[MAXN];
int n;
bool F[MAXN];
ll res1, res2;
void init()
{
scanf("%d", &n); re(i, n) {scanf("%d", &A[i].v); A[i].No = i;}
}
void solve()
{
if (n == 1) {res1 = 0; res2 = 1; return;}
int v0 = A[0].v, v1 = A[n - 1].v, tmp; if (v0 > v1) {tmp = v0; v0 = v1; v1 = tmp;}
sort(A, A + n);
int x = -1, s = 1, No0; ll sum = 0;
re(i, n) {
if (A[i].v > x) {sum += (ll) (A[i].v - x) * s; x = A[i].v;}
No0 = A[i].No;
if (No0 && No0 < n - 1 && !F[No0 - 1] && !F[No0 + 1]) s++;
else if (No0 && No0 < n - 1 && F[No0 - 1] && F[No0 + 1]) s--;
else if (!No0 && F[1]) s--;
else if (No0 == n - 1 && F[n - 2]) s--;
F[No0] = 1;
}
res1 = sum - (v0 + 1); res2 = v1 - v0 + 1;
}
void pri()
{
cout << res1 << endl << res2 << endl;
}
int main()
{
init();
solve();
pri();
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8c3RkaW8uaD4KI2luY2x1ZGUgPHN0ZGxpYi5oPgojaW5jbHVkZSA8c3RyaW5nLmg+CiNpbmNsdWRlIDxhbGdvcml0aG0+CnVzaW5nIG5hbWVzcGFjZSBzdGQ7CiNkZWZpbmUgcmUoaSwgbikgZm9yIChpbnQgaT0wOyBpPG47I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