include [HTML_REMOVED]
using namespace std;
define int long long
define pii pair[HTML_REMOVED]
define inf 0x3f3f3f3f3f3f3f3f
define endl “\n”
define lowbit(x) (x&(-x))
const int N = 2e5+10;
int tr[N];
int n;
void add(int x, int c){
for(int i = x; i <= n; i+=lowbit(i)) tr[i] += c;
}
int qry(int x){
int res = 0;
for(int i = x; i ; i-=lowbit(i)) res += tr[i];
return res;
}
void solve(){
cin >> n;
int sum1 = 0, sum2 = 0;
for(int i = 1; i <= n; i++){
int tmp;
cin >> tmp;
add(tmp,1);
sum1 += (i-qry(tmp-1)-1)(n-tmp-i+qry(tmp-1)+1);
sum2 += (qry(tmp-1))(tmp-1-qry(tmp-1));
}
cout << sum1 << ” ” << sum2 << endl;
}
signed main(){
ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int T=1;
//cin >> T;
while(T–) solve();
return 0;
}
//
//
//
//
//