//树状数组:可以计算一个序列中每个数的前面(正序遍历时)或者后面(倒序遍历时)有多少个数比他小
include [HTML_REMOVED]
include [HTML_REMOVED]
using namespace std;
typedef long long LL;
const int N = 200010;
int n;
//a存储数据y f树状数组
//r当前数的右边,且小于当前数的个数 l当前数左边,且小于当前数的个数
//r2当前数右边,且大于当前数的个数 l2当前数左边,且大于当前数的个数
LL a[N], f[N], r[N], l[N], l2[N], r2[N];
LL query(int x){
LL res = 0;
for(; x; x -= x & (-x)){
res += f[x];
}
return res;
}
void update(LL x, LL y){
for(; x <= n; x += x & (-x)){
f[x] += y;
}
}
int main(){
//读取数据
cin >> n;
for(int i = 0; i < n; ++ i) cin >> a[i];
//倒序扫描a,求出每个a[i]后面有几个数比他小,记录为r[i]
for(int i = n - 1; i >= 0; – i){
r[i] = query(a[i] - 1);
update(a[i], 1);
}
//清空树状数组
memset(f, 0, sizeof f);
//正序扫描a,求出每个a[i]前面有几个数比他小,记录为l[i]
for(int i = 0; i < n; ++ i){
l[i] = query(a[i] - 1);
update(a[i], 1);
}
//由于y1~yn是不重复的1~n,所以对当前元素a[i]
//左边的元素个数是i个,大于a[i]的个数是i-l[i]
//右边的元素个数是n-i-1个,大于a[i]的个数是n-i-1-r[i]
for(int i = 0; i < n; ++ i){
l2[i] = i - l[i];
r2[i] = n - i - 1 - r[i];
}
//res1记录V的个数 res2记录倒V个数
long long res1 = 0, res2 = 0;
for(int i = 0; i < n; ++ i){
res1 += l2[i] * r2[i];
res2 += l[i] * r[i];
}
cout << res1 << ' ' << res2 << endl;
}