#include using namespace std; template struct BinaryIndexedTree { int N; vectorbit; BinaryIndexedTree(){} BinaryIndexedTree(int x) { N = x; bit.resize(x+1); } void add(int x,T y) { while(x <= N) { bit[x] += y; x += x&-x; } } T sum(int x) { T res = 0; while(x) { res += bit[x]; x -= x&-x; } return res; } inline T sum(int l, int r) {//[l,r] return sum(r)-sum(l-1); } inline T operator[](int k) { return sum(k)-sum(k-1); } }; vector cnt(int N,vectorP) { BinaryIndexedTreebit(N); vectorans(N); for(int i = 0; i < N; i++) { ans[i] = bit.sum(P[i]+1,N); bit.add(P[i]+1,1); } return ans; } int main() { int N; cin >> N; vectorA(N),B,C; for(int i = 0; i < N; i++) { cin >> A[i]; if(A[i] <= N/2) { B.push_back(i); } else { C.push_back(i); } } cout << N/2 << " "; if(N%2 == 1) { vectorD; for(int i = 0; i < N/2; i++) { D.push_back(C[i]); D.push_back(B[i]); } D.push_back(C[N/2]); vectorF = cnt(N,D); long long sum = 0; for(int i = 0; i < N; i++) { sum += F[i]; } cout << sum << endl; } else { vectorD,E; for(int i = 0; i < N/2; i++) { D.push_back(C[i]); D.push_back(B[i]); E.push_back(B[i]); E.push_back(C[i]); } vectorF = cnt(N,D),G = cnt(N,E); for(int i = 0; i+1 < N; i++) { F[i+1] += F[i]; } for(int i = N-1; i >= 1; i--) { G[i-1] += G[i]; } long long ans = min(F[N-1],G[0]); for(int i = 1; i+1 < N; i += 2) { ans = min(ans,F[i]+G[i+1]); } cout << ans << endl; } }