N = int(input()) l = list(map(int, input().split())) l.sort() s = set(l) ck1 = 0 if len(s) % 2 == 0: ck = len(s) // 2 ck1 = ck - 1 else: ck = (len(s)+1) // 2 ck_l = list(s) ck = ck_l[ck-1] ck1 = ck_l[max(ck1-1,0)] ans = 0 ans1 = 0 print(ck,ck1) for li in l: ans += abs(ck - li) ans1 += abs(ck1 - li) print(min(ans, ans1))