mod = 998244353 def main(): import sys input = sys.stdin.readline class Bit: def __init__(self, n): self.size = n self.tree = [0] * (n + 1) def sum(self, i): s = 0 while i > 0: s += self.tree[i] i -= i & -i return s def add(self, i, x): while i <= self.size: self.tree[i] += x i += i & -i def lower_bound(self, w): if w <= 0: return 0 x = 0 k = 1 << (self.size.bit_length() - 1) while k: if x + k <= self.size and self.tree[x + k] < w: w -= self.tree[x + k] x += k k >>= 1 return x + 1 N = int(input()) A = list(map(int, input().split())) X = N // 2 C = [] cnt0 = cnt1 = 0 for a in A: if a <= X: C.append(2 + cnt1 * 2) cnt1 += 1 else: C.append(1 + cnt0 * 2) cnt0 += 1 bit = Bit(N) idx = [0] * (N + 1) for i, c in enumerate(C): idx[c] = i + 1 Y = 0 for x in range(N, 0, -1): i = idx[x] Y += bit.sum(i) bit.add(i, 1) if N & 1: print(X, Y) exit() D = [] for i, a in enumerate(A): if a <= X: D.append(i) L = [0] for i, d in enumerate(D): tmp = abs(i * 2 + 1 - d) L.append(L[-1] + tmp) R = [0] for i in range(len(D) - 1, -1, -1): d = D[i] tmp = abs(i * 2 - d) R.append(R[-1] + tmp) R.reverse() Y2 = 10 ** 17 for i in range(len(L)): Y2 = min(Y2, L[i] + R[i]) print(X, min(Y, Y2)) if __name__ == '__main__': main()