#include <iostream>
#include <cstdlib>
#include <string>
#include <cstring>
#include <vector>
#include <algorithm>
#include <queue>
#include <functional>
#include <unordered_set>
#include <unordered_map>
#include <set>
#include <bitset>
#include <cstdio>
using namespace std;
using ll = long long;
// 从左向右依次遍历每个数a[i],使用树状数组统计在i位置之前所有比a[i]大的数的个数、
// 以及比a[i]小的数的个数。统计完成后,将a[i]加入到树状数组。
// 从右向左依次遍历每个数a[i],使用树状数组统计在i位置之后所有比a[i]大的数的个数
// 以及比a[i]小的数的个数。统计完成后,将a[i]加入到树状数组。
const int N = 2e5 + 100;
int n;
// 树状数组的在于维护不同的tree
int nums[N], tree[N];
int Lower[N], Greater[N];
inline int lowbit(int x) {
return x & (-x);
}
inline void add(int x, int k) {
for (int pos = x; pos <= n; pos += lowbit(pos)) tree[pos] += k;
}
inline int query(int x) {
int sum = 0;
for (int pos = x; pos; pos -= lowbit(pos)) {
sum += tree[pos];
}
return sum;
}
int main() {
ios::sync_with_stdio(false);
cin >> n;
for (int i = 1; i <= n; i++) cin >> nums[i];
for (int i = 1; i <= n; i++) {
// 逐步加入,顺序统计
// 用未更新的树状数组统计表示左侧情况
// 统计完后加入该元素更新
int y = nums[i]; //第i个数
//在前面已加入树状数组的所有数中统计在区间[1, y - 1]的数字的出现次数
Lower[i] = query(y - 1);
//在前面已加入树状数组的所有数中统计在区间[y + 1, n]的数字的出现次数
Greater[i] = query(n) - query(y);
//将y加入树状数组,即数字y出现1次
add(y, 1);
}
//清空树状数组,从右往左统计每个位置右边比第i个数y小的数的个数、以及大的数的个数
memset(tree, 0, sizeof tree);
ll resA = 0, resV = 0;
//从右往左统计
for (int i = n; i >= 1; i--) {
int y = nums[i];
resA += (ll) Lower[i] * query(y - 1);
resV += (ll) Greater[i] * (query(n) - query(y));
//将y加入树状数组,即数字y出现1次
add(y, 1);
}
cout << resV << " " << resA << endl;
return 0;
}