Salem gave you $n$ sticks with integer positive lengths $a_1, a_2, \ldots, a_n$.

For every stick, you can change its length to any other positive integer length (that is, either shrink or stretch it). The cost of changing the stick's length from $a$ to $b$ is $|a - b|$, where $|x|$ means the absolute value of $x$.

A stick length $a_i$ is called almost good for some integer $t$ if $|a_i - t| \le 1$.

Salem asks you to change the lengths of some sticks (possibly all or none), such that all sticks' lengths are almost good for some positive integer $t$ and the total cost of changing is minimum possible. The value of $t$ is not fixed in advance and you can choose it as any positive integer. 

As an answer, print the value of $t$ and the minimum cost. If there are multiple optimal choices for $t$, print any of them.


-----Input-----

The first line contains a single integer $n$ ($1 \le n \le 1000$) — the number of sticks.

The second line contains $n$ integers $a_i$ ($1 \le a_i \le 100$) — the lengths of the sticks.


-----Output-----

Print the value of $t$ and the minimum possible cost. If there are multiple optimal choices for $t$, print any of them.


-----Examples-----
Input
3
10 1 4

Output
3 7

Input
5
1 1 2 2 3

Output
2 0



-----Note-----

In the first example, we can change $1$ into $2$ and $10$ into $4$ with cost $|1 - 2| + |10 - 4| = 1 + 6 = 7$ and the resulting lengths $[2, 4, 4]$ are almost good for $t = 3$.

In the second example, the sticks lengths are already almost good for $t = 2$, so we don't have to do anything.

Difficulty: EASY

Solutions:
n = map(int, input())
a = list(map(int, input().split()))
a.sort()
Max = 1000000000000
ans = 1000000000000
for x in range(1, 101):
	sum = 0
	for y in a:
		k = abs(x - y)
		k = min(k, abs(k - 1))
		sum += k
	if sum < Max:
		ans = x
		Max = sum
print(ans, end=' ')
print(Max)


n = int(input())
a = list(map(int, input().split()))
a.sort()
mx = 0
foo = 10000000
k = 0
for i in range(1, max(a) + 1):
	for j in range(n):
		if i != a[j]:
			mx += abs(i - a[j]) - 1
	if foo > mx:
		foo = mx
		k = i
	mx = 0
print(k, foo)


n = int(input())
arr = list(map(int, input().split()))

def findCost(t):
	ans = 0
	for x in arr:
		li = []
		li.append(abs(t - x))
		li.append(abs(t + 1 - x))
		li.append(abs(t - 1 - x))
		ans += min(li)
	return ans
costs = []
for i in range(1, 100):
	costs.append(findCost(i))
print(costs.index(min(costs)) + 1, min(costs))


def func(arr, check):
	tot = 0
	for x in range(len(arr)):
		if arr[x] > check + 1:
			tot += arr[x] - check - 1
		elif arr[x] < check - 1:
			tot += check - 1 - arr[x]
	return tot

def main():
	n = int(input())
	arr = input().split()
	tot = 0
	for x in range(n):
		arr[x] = int(arr[x])
		tot += arr[x]
	mini = 10 ** 10
	val = 0
	for x in range(1, 101):
		test = func(arr, x)
		if mini > test:
			mini = test
			val = x
	print(val, mini)
main()


n = [int(i) for i in input().split()][0]
a = [int(i) for i in input().split()]
t = 0
tend = 102
dv = 10000000
for i in range(1, tend):
	d = 0
	for ai in a:
		d += min(min(abs(i - ai), abs(i - 1 - ai)), abs(i + 1 - ai))
	if d < dv:
		dv = d
		t = i
print(t, dv)


n = int(input())
a = [int(x) for x in input().split()]
t_min = 100
r_min = -1
for t in range(1, 100):
	r = 0
	for aa in a:
		if aa > t + 1:
			r += aa - t - 1
		elif aa < t - 1:
			r += t - 1 - aa
	if r < r_min or r_min == -1:
		t_min = t
		r_min = r
print(t_min, r_min)


n = int(input())
a = [int(x) for x in input().split()]
ans = 100000
for i in range(1, 101):
	s = sum([abs(b - i) - 1 * (b != i) for b in a])
	if s < ans:
		ans = s
		t = i
print(t, ans)


n = int(input())
a = list(map(int, input().split()))
a.sort()
ans = 9999999999
t = -1
for num in range(1, a[-1] + 1):
	temp = 0
	for b in a:
		if b < num:
			temp += num - b - 1
		elif b > num:
			temp += b - num - 1
	if temp < ans:
		ans = temp
		t = num
print('{} {}'.format(t, ans))


n = int(input())
arr = list(map(int, input().split()))
mx = max(arr)
min_val = 99999999999999
t = -1
for i in range(1, mx + 1):
	val = 0
	for j in range(n):
		val += min(abs(arr[j] - i), abs(arr[j] - (i - 1)), abs(arr[j] - (i + 1)))
	if val < min_val:
		min_val = val
		t = i
print(t, min_val)


def solve(t):
	cnt = 0
	for i in a:
		if abs(i - t) >= 1:
			if i > t:
				cnt += i - t - 1
			else:
				cnt += t - i - 1
	return cnt
n = int(input())
a = list(map(int, input().split()))
t_now = -1
ans = 10000000
for t in range(1, 101):
	now = solve(t)
	if now < ans:
		t_now = t
		ans = now
print(t_now, ans)


import math
n = int(input())
ar = [*map(int, input().split(' '))]
(mint, mincost) = (int(1000000000.0), int(1000000000.0))
for i in range(1, 105):
	cost = sum([min(abs(x - i), abs(x - i - 1), abs(x - i + 1)) for x in ar])
	if cost < mincost:
		mincost = cost
		mint = i
print(int(mint), int(mincost))


n = int(input())
a = list((int(x) for x in input().split()))
res = 9999999999
len = 1
for t in range(1, 101):
	cost = 0
	for x in a:
		cost += min(abs(x - t), min(abs(x - t - 1), abs(x - t + 1)))
	if res > cost:
		res = cost
		len = t
print(len, res)


import math
n = int(input())
arr = list(map(int, input().split()))
mm = 1000000000000000
ft = -1
for t in range(1, 101):
	ans = 0
	for i in range(n):
		if arr[i] > t + 1:
			ans += arr[i] - t - 1
		if arr[i] < t - 1:
			ans += t - 1 - arr[i]
	if ans < mm:
		mm = ans
		ft = t
print(ft, mm)


n = int(input())
l = list(map(int, input().split()))
ans = [0] * 101
for i in range(1, 101):
	for k in range(n):
		ans[i] += max(abs(l[k] - i) - 1, 0)
cnt = [100000000, 100000000]
for i in range(1, 101):
	if cnt[1] > ans[i]:
		cnt[0] = i
		cnt[1] = ans[i]
print(cnt[0], cnt[1])


n = int(input())
a = list(map(int, input().split()))
a.sort()
if len(a) % 2 == 0:
	x = len(a) // 2
	t = int((a[x] + a[x - 1]) // 2)
else:
	x = len(a) // 2
	t = int(a[x])
m = 9999999
for t in range(1, 100 + 1):
	c = 0
	for i in a:
		if i < t:
			c += abs(t - 1 - i)
		elif i > t:
			c += abs(i - t - 1)
		else:
			pass
	if c < m:
		m = c
		nt = t
print(nt, m)


n = int(input())
a = [int(x) for x in input().split()]
(ans, t) = min(((sum([min(abs(b - i), abs(b - i - 1), abs(b - i + 1)) for b in a]), i) for i in range(1, 101)))
print(t, ans)


n = int(input())
a = list(map(int, input().split()))
T = 0
ans = float('inf')
for t in range(1, 101):
	cost = 0
	for i in range(n):
		if a[i] > t:
			cost += a[i] - (t + 1)
		elif a[i] < t:
			cost += t - (a[i] + 1)
	if cost < ans:
		ans = cost
		T = t
print(T, ans)


n = int(input())
a = [int(t) for t in input().split(' ')]
mincost = 1000 * 100 + 1
best_t = None
for t in range(1, 101):
	cost = 0
	for x in a:
		cost += max(0, abs(x - t) - 1)
	if cost < mincost:
		mincost = cost
		best_t = t
print(best_t, mincost)


maxs = 100000000000.0
lens = int(input())
arrs = [int(x) for x in input().split()]
for i in range(1, 101):
	now = sum([abs(i - j) - 1 for j in arrs if i != j])
	if now < maxs:
		diff = i
		cnt = now
		maxs = now
print(diff, cnt)


import sys
stdin = sys.stdin
sys.setrecursionlimit(10 ** 5)

def li():
	return map(int, stdin.readline().split())

def li_():
	return map(lambda x: int(x) - 1, stdin.readline().split())

def lf():
	return map(float, stdin.readline().split())

def ls():
	return stdin.readline().split()

def ns():
	return stdin.readline().rstrip()

def lc():
	return list(ns())

def ni():
	return int(stdin.readline())

def nf():
	return float(stdin.readline())
n = ni()
a = list(li())
anst = 0
anscost = float('inf')
for t in range(1, 1001):
	cost = 0
	for ai in a:
		if ai < t - 1:
			cost += t - 1 - ai
		elif ai > t + 1:
			cost += ai - (t + 1)
	if cost < anscost:
		anscost = cost
		anst = t
print(anst, anscost)


n = int(input())
a = list(map(int, input().split()))

def f(t):
	d = 0
	for i in a:
		if i > t + 1:
			d += i - t - 1
		elif i < t - 1:
			d += t - 1 - i
	return d
b = 1
d = f(1)
for i in range(1, 101):
	dd = f(i)
	if dd < d:
		d = dd
		b = i
print(b, d)


n = int(input())
arr = [int(x) for x in input().split()]
t = []
for i in range(101):
	s = 0
	for j in arr:
		s += max(0, abs(j - i) - 1)
	t.append(s)
p = t[1:].index(min(t)) + 1
print(p, min(t))


n = int(input())
a = [int(x) for x in input().split()]
ans = 0
anst = 1000000
for i in range(1, max(a) + 1):
	temp = 0
	for j in a:
		if abs(i - j) <= 1:
			continue
		temp += max(0, min(abs(j - (i - 1)), abs(j - (i + 1))))
	if temp < anst:
		ans = i
		anst = temp
print(ans, anst)


n = int(input())
a = list(map(int, input().split()))
m = 100000
for t in range(1, 101):
	s = 0
	for x in a:
		if abs(t - x) > 1:
			s += abs(t - x) - 1
	if s < m:
		m = s
		mi = t
print(mi, m)


n = int(input())
arr = list(map(int, input().split()))
arr.sort()
ap = float('inf')
at = -1
for t in range(1, 101):
	s = 0
	for c in arr:
		s += max(abs(c - t) - 1, 0)
	if s < ap:
		ap = s
		at = t
print(at, ap)


from typing import List
_max_a = 100

def cost(a: List[int], t: int, n: int) -> int:
	return sum((max(abs(a[i] - t) - 1, 0) for i in range(n)))
n = int(input())
a = list(map(int, input().split()))
answers = []
for t in range(1, _max_a + 1):
	answers.append(cost(a, t, n))
optimal_cost = min(answers)
optimal_t = answers.index(optimal_cost) + 1
print(optimal_t, optimal_cost)


import os
import heapq
import sys, threading
import math
import bisect
import operator
from collections import defaultdict
sys.setrecursionlimit(10 ** 5)
from io import BytesIO, IOBase

def gcd(a, b):
	if b == 0:
		return a
	else:
		return gcd(b, a % b)

def power(x, p, m):
	res = 1
	while p:
		if p & 1:
			res = res * x % m
		x = x * x % m
		p >>= 1
	return res

def inar():
	return [int(k) for k in input().split()]

def lcm(num1, num2):
	return num1 * num2 // gcd(num1, num2)

def main():
	t = 1
	for _ in range(t):
		n = int(input())
		arr = inar()
		t = 1
		ans = 10 ** 5
		for i in range(1, 101):
			temp = 0
			for j in range(n):
				if abs(arr[j] - i) <= 1:
					continue
				else:
					temp += abs(arr[j] - i) - 1
			if temp < ans:
				ans = temp
				t = i
		print(t, ans)
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


a = int(input())
h = list(map(int, input().split()))
minn = []
for i in range(1, 101):
	minn.append(0)
	for u in h:
		p = abs(u - i)
		if p != 0:
			p -= 1
		minn[i - 1] += p
print(minn.index(min(minn)) + 1, min(minn))


n = int(input())
l = [*map(int, input().split())]

def f(a):
	return [sum((min([abs(e - a), abs(e - (a - 1)), abs(e - (a + 1))]) for e in l)), a]
res = [float('inf'), float('inf')]
for a in range(1, 101):
	res = min(res, f(a))
print(res[1], res[0])


n = int(input())
a = input()
a = [int(x) for x in a.split()]
t1 = int(sum(a) / n)
t2 = t1 + 1
t3 = t1 - 1

def prove(t):
	suma = 0
	for x in a:
		if x > t:
			suma += x - 1 - t
		elif x < t:
			suma += t - x - 1
	return suma
almost = min([(prove(b), b) for b in range(1, 100)])
t = almost[1]
ans = almost[0]
print(str(t) + ' ' + str(ans))


n = int(input())
A = list(map(int, input().split()))
t = 1
maxi = 1000000
ans = 0
f = 1
for t in range(1, 100, 1):
	ans = 0
	for i in range(n):
		if A[i] > t:
			ans = ans + A[i] - t - 1
		if A[i] < t:
			ans = ans + t - 1 - A[i]
	if ans < maxi:
		maxi = ans
		f = t
print(f, maxi)


n = int(input())
l = list(map(int, input().split()))
l.sort()
min = 10 ** 12
for t in range(1, 101):
	cost = 0
	for j in range(n):
		if abs(l[j] - t) > 1:
			if l[j] > t:
				cost += l[j] - (1 + t)
			else:
				cost += t - 1 - l[j]
	if cost < min:
		min = cost
		ans = t
print(ans, min)


n = int(input())
a = [int(i) for i in input().split()]
val = minval = 10000000000.0
t1 = 0
for t in range(101):
	for i in a:
		if i < t - 1:
			val += t - 1 - i
		elif i > t + 1:
			val += i - t - 1
	if minval > val:
		minval = val
		t1 = t
	val = 0
print(t1, minval)


n = int(input())
arr = list(map(int, input().split()))
x = max(arr)
ans = 99999999
for t in range(1, x + 2):
	sum = 0
	for i in arr:
		sum += min(abs(t - i), abs(t - i - 1), abs(t - i + 1))
	if sum < ans:
		ans = sum
		T = t
print(T, ans)


gi = lambda : list(map(int, input().split()))
(n,) = gi()
l = gi()
ans = 1
cost = 1000000
for k in range(1, 101):
	if sum([abs(e - k) - 1 if abs(e - k) > 1 else 0 for e in l]) < cost:
		ans = k
		cost = sum([abs(e - ans) - 1 if abs(e - ans) > 1 else 0 for e in l])
print(ans, cost)


def main():
	n = int(input())
	a = list(map(int, input().split()))
	ret = [0, 100 * 1000]
	for x in range(1, 101):
		total_cost = 0
		for v in a:
			total_cost += min(abs(x + 1 - v), abs(x - v), abs(x - 1 - v))
		if total_cost < ret[1]:
			ret = [x, total_cost]
	print(ret[0], ret[1])
main()


n = int(input())
l = list(map(int, input().split()))
INF = max(l) * n
s = 0
m = []
for t in range(1, max(l) + 1):
	for i in l:
		if t > i + 1:
			s += t - i - 1
		elif t < i - 1:
			s += i - t - 1
	m.append(s)
	s = 0
print(m.index(min(m)) + 1, min(m))


n = int(input())
a = list(map(int, input().split()))
ans = int(1000000000.0)
arg = 0
for t in range(1, 101):
	cost = 0
	for x in a:
		if x > t:
			cost = cost + x - t - 1
		elif x < t:
			cost = cost + t - 1 - x
	if cost < ans:
		ans = cost
		arg = t
print(arg, ans)


n = int(input())
stk = list(map(int, input().split()))
(t, mn) = (0, 1000000)
for i in range(1, 101):
	s = 0
	for j in range(n):
		s += min(abs(stk[j] - i), abs(stk[j] - i - 1), abs(stk[j] - i + 1))
	if mn > s:
		(t, mn) = (i, s)
print(t, mn)


from typing import List
_max_a = 100

def dist(x: int, y: int, w: int=1):
	if x < y - w:
		return y - w - x
	elif x > y + w:
		return x - (y + w)
	else:
		return 0

def cost(a: List[int], t: int, n: int) -> int:
	ans = 0
	for i in range(n):
		ans += dist(a[i], t)
	return ans
n = int(input())
a = list(map(int, input().split()))
answers = []
for t in range(1, _max_a + 1):
	answers.append(cost(a, t, n))
optimal_cost = min(answers)
optimal_t = answers.index(optimal_cost) + 1
print(optimal_t, optimal_cost)


n = int(input())
l = list(map(int, input().split()))
mincost = 100000
ans = 0
for t in range(1, 101):
	curcost = 0
	for i in l:
		if i == t:
			continue
		else:
			curcost += abs(t - i) - 1
	if curcost < mincost:
		mincost = curcost
		ans = t
print(ans, mincost)


_ = int(input())
a = [int(_) for _ in input().split(' ')]
minc = 2000000000
t = 0
for i in range(1, 101):
	c = 0
	for j in a:
		c += max(abs(j - i) - 1, 0)
	if c < minc:
		t = i
		minc = c
print(t, minc)


n = int(input())
L = [int(x) for x in input().split()]
L.sort()
arr = [0, 500500]
for i in range(1, 101):
	Sum = 0
	for x in L:
		if abs(x - i) > 1:
			Sum += abs(x - i) - 1
	if arr[1] > Sum:
		arr[1] = Sum
		arr[0] = i
print(arr[0], arr[1])


n = int(input())
sticks = list(map(int, input().split()))
smin = 10000000000000000000
tmin = -1
for t in range(1, 102):
	s = 0
	for l in sticks:
		if abs(t - l) <= 1:
			continue
		if l < t:
			s += t - 1 - l
		else:
			s += l - t - 1
	if s < smin:
		smin = s
		tmin = t
print(tmin, smin)


n = int(input())
a = list(map(int, input().split(' ')))
l = [x for x in range(1, max(a) + 1)]
k = []
for i in l:
	x = 0
	for j in a:
		if abs(j - i) > 1:
			if j > i:
				x += abs(j - i - 1)
			else:
				x += abs(i - j - 1)
		else:
			x += 0
	k.append(x)
print(k.index(min(k)) + 1, min(k))


n = int(input())
a = [int(i) for i in input().split()]
b = []
for k in range(1, 105):
	p = 0
	for i in range(n):
		if abs(a[i] - k) >= 1:
			p = p + (abs(a[i] - k) - 1)
	b.append((p, k))
l = min(b)
print(*l[::-1])


import re, math, decimal, bisect

def read():
	return input().strip()

def iread():
	return int(input().strip())

def viread():
	return [int(_) for _ in input().strip().split()]
n = iread()
sticks = viread()
best = None
for t in range(1, 101):
	cost = 0
	for s in sticks:
		if s > t + 1:
			cost += s - (t + 1)
		elif s < t - 1:
			cost += t - 1 - s
	if best is None or cost < best[1]:
		best = (t, cost)
print(*best)


n = int(input())
a = list(map(int, input().split()))
num = float('inf')
ans = -1
for t in range(1, 105):
	tmp = 0
	for j in range(n):
		tmp += min(min(abs(a[j] - (t - 1)), abs(a[j] - t)), abs(a[j] - (t + 1)))
	if tmp < num:
		num = tmp
		ans = t
print(ans, num)


n = int(input())
ns = list(map(int, input().split()))
cost = int(1000000000.0)
res = 0
for t in range(1, 101):
	temp = 0
	for i in ns:
		if abs(i - t) > 1:
			temp += abs(i - t) - 1
	if cost > temp:
		cost = temp
		res = t
print(res, cost)


n = int(input())
ar = list(map(int, input().strip().split(' ')))
ar.sort()
m = 10 ** 5
t = 0
i = 1
while i <= 100:
	c = 0
	d = 0
	for j in range(n):
		c += abs(ar[j] - i)
		if ar[j] == i:
			d += 1
	c -= n - d
	if c < m:
		m = c
		t = i
	i += 1
print(t, m, end=' ')


import sys
import math
import bisect

def solve(A):
	n = len(A)
	min_cost = 10 ** 18
	sol = -1
	for i in range(1, 101):
		cost = 0
		for a in A:
			if a > i + 1:
				cost += a - (i + 1)
			elif a < i - 1:
				cost += i - 1 - a
		if min_cost > cost:
			min_cost = cost
			sol = i
	return (sol, min_cost)

def main():
	n = int(input())
	A = list(map(int, input().split()))
	(sol, min_cost) = solve(A)
	print('%d %d' % (sol, min_cost))
main()


n = int(input())
a = [int(a) for a in input().split()]
t = round(sum(a) / len(a))

def cost(t):
	c = 0
	for x in a:
		if x < t - 1:
			c += t - 1 - x
		elif t + 1 < x:
			c += x - t - 1
	return c
best = 0
bestcost = 10 ** 20
for x in range(1, 101):
	c = cost(x)
	if c < bestcost:
		best = x
		bestcost = c
print(best, bestcost)


from itertools import combinations
from sys import stdin
import math

def listIn():
	return list(map(int, stdin.readline().strip().split()))

def stringIn():
	return [x for x in stdin.readline().split()]

def intIn():
	return int(stdin.readline())
n = intIn()
a = listIn()
a = sorted(a)
b = sorted(set(a))
l = len(b)
cost = float('inf')
for ele in b:
	t = list(range(ele - 1, ele + 2))
	for tt in t:
		if tt > 0:
			c = 0
			for i in range(n):
				d = abs(a[i] - tt)
				if d <= 1:
					c = c
				else:
					c += d - 1
			if c < cost:
				cost = c
				ttt = tt
print(ttt, cost)


t = int(input())
arr = list(map(int, input().split()))
arr2 = []
sum = 0
for x in range(max(arr)):
	sum = 0
	for y in arr:
		if x + 1 < y:
			sum = sum + y - x - 2
		if x + 1 > y:
			sum = sum + x - y
	arr2.append((sum, x + 1))
print('{} {}'.format(min(arr2)[1], min(arr2)[0]))


import math

def list_input():
	return list(map(int, input().split()))

def num_input():
	return map(int, input().split())

def string_list():
	return list(input())
n = int(input())
arr = list_input()
cost = 10 ** 8
ans = 0
for i in range(1, 101):
	temp = 0
	for j in arr:
		if abs(i - j) > 1:
			temp += abs(i - j) - 1
	if cost != min(cost, temp):
		cost = min(cost, temp)
		ans = i
print(ans, cost)


import math
n = input()
a = list(map(int, input().split()))
ans_i = 1
ans_s = 1000000000
for t in range(1, 101):
	sum = 0
	for i in a:
		if abs(i - t) >= 1:
			sum += abs(i - t) - 1
	if sum < ans_s:
		ans_s = sum
		ans_i = t
print(ans_i, ans_s)


input()
A = list(map(int, input().split()))
print(*min(((t, sum((max(0, abs(t - a) - 1) for a in A))) for t in range(1, 101)), key=lambda x: x[1]))


stick_no = int(input().strip())
sticks = [int(x) for x in input().strip().split(' ')]

def cost(x):
	res = 0
	for s in sticks:
		if s > x:
			res += s - x - 1
		elif s < x:
			res += x - s - 1
	return res
c_r = 10000000
c_i = -1
for i in range(1, 100):
	c = cost(i)
	if c < c_r:
		c_r = c
		c_i = i
print(c_i, c_r)


n = int(input())
sticks = [int(i) for i in input().split()]
best = 1000000000
bestt = -1
for t in range(1, 101):
	cost = 0
	for stick in sticks:
		if stick > t:
			cost += abs(stick - (t + 1))
		elif stick < t:
			cost += abs(stick - (t - 1))
	if cost < best:
		best = cost
		bestt = t
print(bestt, best)


n = int(input())
l = []
q = []
p = input().rstrip().split(' ')
x = list(p)
x.sort(key=int, reverse=True)
for i in range(1, int(x[0]) + 1):
	s = 0
	for j in range(0, len(p)):
		t = abs(int(p[j]) - i)
		if t > 1:
			o = i + 1
			O = i - 1
			d = abs(int(p[j]) - O)
			D = abs(int(p[j]) - o)
			s = s + min(d, D)
	l.append(s)
	q.append(i)
print(q[l.index(min(l))], min(l))


n = int(input())
a = list(map(int, input().split()))
ma = 10000000
t = 0
for i in range(1, 101):
	s = 0
	for j in range(n):
		k = min(abs(a[j] - i), abs(abs(a[j] - i) - 1))
		s += abs(k)
	if s < ma:
		ma = s
		t = i
print(t, ma)


n = input()
a = list(map(int, input().split()))
a.sort()
if len(a) % 2 == 1:
	t = a[len(a) // 2]
	x = [t - 1, t, t + 1]
else:
	x = [a[len(a) // 2 - 1] - 1, a[len(a) // 2 - 1], a[len(a) // 2 - 1] + 1, a[len(a) // 2] - 1, a[len(a) // 2], a[len(a) // 2] + 1]
if 0 in x:
	x.remove(0)
res = [0] * len(x)
for i in range(len(a)):
	for z in range(len(x)):
		if a[i] < x[z] - 1:
			res[z] = res[z] + (x[z] - 1) - a[i]
		elif a[i] > x[z] + 1:
			res[z] = res[z] + a[i] - (x[z] + 1)
for z in range(len(x)):
	if res[z] == min(res):
		print(x[z], res[z])
		exit()


class CodeforcesTask1105ASolution:

	def __init__(self):
		self.result = ''
		self.n = 0
		self.sticks = []

	def read_input(self):
		self.n = int(input())
		self.sticks = [int(x) for x in input().split(' ')]

	def process_task(self):
		mn = 10 ** 9
		ct = -1
		for t in range(1, 101):
			tc = 0
			for stick in self.sticks:
				if stick > t:
					tc += stick - t - 1
				elif stick < t:
					tc += t - stick - 1
			if tc < mn:
				mn = tc
				ct = t
		self.result = '{0} {1}'.format(ct, mn)

	def get_result(self):
		return self.result
Solution = CodeforcesTask1105ASolution()
Solution.read_input()
Solution.process_task()
print(Solution.get_result())


import math
n = int(input())
A = [int(i) for i in input().split()]
A.sort()
ans = 10 ** 18
val = 0
for mid in range(1, 100):
	cost = 0
	for i in range(n):
		cost += min(abs(A[i] - mid), abs(A[i] - mid + 1), abs(A[i] - mid - 1))
	if cost < ans:
		ans = cost
		val = mid
print(val, ans)


n = int(input())
a = list(map(int, input().split()))
t = 0
mn = 1000000000
for i in range(1, 100):
	cur = 0
	for j in range(n):
		cur += max(0, abs(i - a[j]) - 1)
	if cur < mn:
		mn = cur
		t = i
print(t, mn)


n = int(input())
cost1 = []
flag = 1
k = list(map(int, input().split()))
for i in range(1, 101):
	cost = 0
	for o in k:
		if o < i:
			cost = cost + abs(o - (i - 1))
		elif o > i:
			cost = cost + abs(o - (i + 1))
		else:
			cost += 0
	cost1.append(cost)
t = min(cost1)
print(cost1.index(t) + 1, t)


n = int(input())
L = [int(x) for x in input().split()]
S = sum(L)
best = 10 ** 10
ans = None
for i in range(1, 200):
	temp = 0
	for j in L:
		temp += min(abs(j - i - 1), abs(j - i), abs(j - i + 1))
	if best > temp:
		best = temp
		ans = i
print(ans, best)


n = int(input())
a = list(map(int, input().split()))
cost = 999999999
tf = 0
for t in range(1, 101):
	count = 0
	for i in range(n):
		count += max(abs(a[i] - t) - 1, 0)
	if count < cost:
		cost = count
		tf = t
print(tf, cost)


import math as ma
import sys
from sys import exit
from decimal import Decimal as dec
from itertools import permutations

def li():
	return list(map(int, input().split()))

def num():
	return map(int, input().split())

def nu():
	return int(input())
mm = 1000000007
t = 1
for it in range(t):
	n = nu()
	a = li()
	mx = 999999999999
	vv = -1
	for i in range(1, 101):
		s = 0
		for j in range(n):
			if a[j] < i:
				if i == 1:
					continue
				s += abs(a[j] - (i - 1))
			elif a[j] > i:
				s += abs(a[j] - (i + 1))
		if s < mx:
			vv = i
			mx = s
	print(vv, mx)


n = int(input())
a = list(map(int, input().split()))
maxi = 100000000
ans = -1
for t in range(1, 101):
	cur = 0
	for i in a:
		cur += min(abs(i - t), abs(i - t - 1), abs(i - t + 1))
	if cur < maxi:
		maxi = cur
		ans = t
print(ans, maxi)


n = int(input())
a = [int(i) for i in input().split()]
t = 1
mins = 1000000
while t < 100:
	su = 0
	for e in a:
		if e > t:
			su += e - t - 1
		elif e < t:
			su += t - 1 - e
	if su < mins:
		mins = su
		res = t
	t += 1
print(res, mins)


R = lambda : map(int, input().split())
n = int(input())
L = list(R())
(t, res) = (0, 10 ** 5)
for i in range(1, 101):
	s = 0
	for j in L:
		if abs(j - i) > 1:
			s += abs(j - i) - 1
	if s < res:
		res = s
		t = i
print(t, res)


from sys import stdin, stdout
from collections import defaultdict
import math
I = stdin.readline
P = stdout.write
n = int(I())
arr = [int(x) for x in I().split()]
t = 1
ans = math.inf
for i in range(1, max(arr) + 1):
	now = 0
	for j in arr:
		if j < i:
			now += i - 1 - j
		elif j > i:
			now += j - i - 1
	if now < ans:
		ans = now
		t = i
print(t, ans)


n = int(input())
l = list(map(int, input().split()))
m = 9999999
t1 = 0
for t in range(1, 101):
	c = 0
	for i in l:
		if abs(i - t) > 1:
			c += min(abs(t - i), abs(abs(t - i) - 1))
	if c < m:
		t1 = t
		m = c
print(str(t1) + ' ' + str(m))


_max_a = 100
n = int(input())
a = list(map(int, input().split()))
answers = [sum((max(abs(a[i] - t) - 1, 0) for i in range(n))) for t in range(1, _max_a + 1)]
optimal_cost = min(answers)
print(answers.index(optimal_cost) + 1, optimal_cost)


n = int(input())
a = [int(i) for i in input().split()]
count = 1000000
for i in range(1, 101):
	cost = sum((0 if j == i else abs(i - j) - 1 for j in a))
	if cost < count:
		count = cost
		t = i
print(t, count)


n = int(input())
sticks = list(map(int, input().split()))
costs = []
for i in range(1, max(sticks) + 1):
	cost = 0
	for j in range(0, len(sticks)):
		cost += max(abs(i - sticks[j]) - 1, 0)
	costs.append(cost)
min_cost = min(costs)
print(costs.index(min_cost) + 1, min_cost)


n = int(input())
ai = list(map(int, input().split()))
ti = 0
mini = 10 ** 7
for t in range(1, 101):
	num = 0
	for i in ai:
		num += max(abs(i - t) - 1, 0)
	if num < mini:
		ti = t
		mini = num
print(ti, mini)


n = int(input())
a = list(map(int, input().split()))
m = 100000000
k = -1
for i in range(1, 101):
	sum = 0
	for j in range(n):
		if a[j] != i:
			sum = abs(i - a[j]) - 1 + sum
	if sum < m:
		k = i
		m = sum
print(k, m)


n = int(input())
ans = 10 ** 18
val = -1
arr = list(map(int, input().split()))
for i in range(1, 102):
	valx = 0
	for j in arr:
		if abs(j - i) > 1:
			valx += abs(j - i) - 1
	if valx < ans:
		ans = valx
		val = i
print(val, ans)


n = int(input())
a = [int(x) for x in input().split()]
ans = -1
Sum = 999999999
for i in range(1, 100):
	tmp = 0
	for j in a:
		if abs(i - j) > 1:
			tmp += max(0, min(abs(j - (i - 1)), abs(j - (i + 1))))
	if tmp < Sum:
		Sum = tmp
		ans = i
print(ans, Sum)


TN = 1

def solution():
	n = int(input())
	a = list(map(int, input().split()))
	ans = [0 for i in range(100)]
	for t in range(1, 101):
		for i in range(n):
			if a[i] - t > 1:
				ans[t - 1] += a[i] - t - 1
			elif a[i] - t < -1:
				ans[t - 1] += t - 1 - a[i]
	ind = ans.index(min(ans))
	print(ind + 1, ans[ind])
while TN != 0:
	solution()
	TN -= 1


import sys
n = int(input())
a = list(map(int, input().split()))
mi = 0
mis = sys.maxsize
for t in range(1, 101):
	k = 0
	for i in a:
		if abs(i - t) > 1:
			k += abs(i - t) - 1
	if k < mis:
		mis = k
		mi = t
print(mi, mis)


a = int(input())
z = list(map(int, input().split()))
import math
mini = math.inf
inde = 0
for i in range(1, 101):
	count = 0
	for j in range(len(z)):
		if z[j] > i:
			count += z[j] - 1 - i
		elif z[j] < i:
			count += i - 1 - z[j]
	if count < mini:
		mini = count
		inde = i
print(inde, mini)


def main():
	n = int(input())
	arr = list(map(int, input().split()))
	min_t = -1
	min_cost = float('inf')
	for t in range(1, 102):
		cost = 0
		for i in arr:
			if abs(i - t) > 1:
				if i > t:
					cost += i - t - 1
				else:
					cost += t - 1 - i
		if cost < min_cost:
			min_cost = cost
			min_t = t
	print(min_t, min_cost)
main()


n = int(input())
lens = [int(x) for x in input().split()]
num___cost = [100 * 1001]
for i in range(1, 101):
	cost = sum([max(0, abs(i - x) - 1) for x in lens])
	num___cost.append(cost)
ans = min(enumerate(num___cost), key=lambda x: x[1])
print(*ans)


n = int(input())
ar = list(map(int, input().split()))
cl = []
for t in range(1, 101):
	cl.append(0)
	for n in ar:
		p = abs(n - t)
		if p != 0:
			p -= 1
		cl[t - 1] += p
print(cl.index(min(cl)) + 1, min(cl))


from bisect import bisect_right as br
from bisect import bisect_left as bl
from collections import defaultdict
from itertools import combinations
import functools
import sys
import math
MAX = sys.maxsize
MAXN = 10 ** 6 + 10
MOD = 10 ** 9 + 7

def isprime(n):
	n = abs(int(n))
	if n < 2:
		return False
	if n == 2:
		return True
	if not n & 1:
		return False
	for x in range(3, int(n ** 0.5) + 1, 2):
		if n % x == 0:
			return False
	return True

def mhd(a, b, x, y):
	return abs(a - x) + abs(b - y)

def numIN():
	return map(int, sys.stdin.readline().strip().split())

def charIN():
	return sys.stdin.readline().strip().split()

def ncr(n, k):
	res = 1
	c = [0] * (k + 1)
	c[0] = 1
	for i in range(1, n + 1):
		for j in range(min(i, k), 0, -1):
			c[j] = (c[j] + c[j - 1]) % MOD
	return c[k]
n = int(input())
l = list(numIN())
mn = MAX
ft = -1
for i in range(1, 102):
	t = i
	ans = 0
	for j in range(n):
		if abs(l[j] - t) > 1:
			if l[j] > t:
				ans += l[j] - (t + 1)
			else:
				ans += t - 1 - l[j]
	if ans < mn:
		mn = ans
		ft = t
print(ft, mn)


n = int(input())
a = list(map(int, input().split()))
(anst, ans) = (0, 1000000)
for t in range(1, 101):
	tmp = 0
	for i in a:
		if i != t:
			tmp += abs(i - t) - 1
	if tmp < ans:
		ans = tmp
		anst = t
print(anst, end=' ')
print(ans)


def cnt(a, t):
	s = 0
	for aa in a:
		if aa < t - 1:
			s += t - 1 - aa
		elif aa > t + 1:
			s += aa - (t + 1)
	return s
n = int(input())
a = list(map(int, input().split()))
mn = 10 ** 19
tt = 0
for t in range(1, 101):
	ss = cnt(a, t)
	if ss < mn:
		mn = ss
		tt = t
print(tt, mn)


n = int(input())
a = list(map(int, input().split()))
cost = 10 ** 10
tt = 0
for t in range(1, 101):
	c = 0
	for i in a:
		if abs(i - t) > 1:
			if i < t:
				c += t - i - 1
			elif i > t:
				c += i - t - 1
	if c < cost:
		tt = t
		cost = min(cost, c)
print(tt, cost)


def main():
	n = int(input())
	a = list(map(int, input().split()))
	r = max(a)
	mini_count = 1000001
	k = -1
	for i in range(1, r + 1):
		temp = 0
		for j in a:
			if j < i:
				temp += abs(i - 1 - j)
			elif j > i:
				temp += abs(i + 1 - j)
		if temp < mini_count:
			mini_count = temp
			k = i
	print(k, mini_count)
main()


n = int(input())
arr = list(map(int, input().split()))

def solve(arr):
	minCost = 10 ** 5
	i = 1
	for mean in range(1, 101):
		cost = 0
		for num in arr:
			val = abs(num - mean)
			if val > 0:
				cost += val - 1
		if minCost > cost:
			minCost = cost
			i = mean
	return (i, minCost)
(mean, cost) = solve(arr)
print(mean, cost)


n = int(input())
a = [*map(int, input().split())]
ans = {}
for i in range(1, 101):
	temp = 0
	for j in a:
		if i == j:
			continue
		temp += min(abs(j - i - 1), abs(j - i + 1))
	ans[i] = temp
print(min(ans, key=ans.get), ans[min(ans, key=ans.get)])


def solve(arr, x):
	cost = 0
	for i in arr:
		if i == x:
			continue
		elif i < x:
			cost += abs(x - i - 1)
		else:
			cost += abs(x - i + 1)
	return cost
n = int(input())
arr = list(map(int, input().split()))
minn = 10 ** 100
index = 0
for i in range(1, 105):
	cost = solve(arr, i)
	if cost < minn:
		minn = cost
		index = i
print(index, minn)


n = int(input())
a = [int(o) for o in input().split()]
ans = []
for i in range(1, 101):
	su = 0
	for j in range(n):
		su += min(abs(i - a[j]), abs(i + 1 - a[j]), abs(i - 1 - a[j]))
	ans.append([su, i])
lol = min(ans[:])
print(*lol[::-1])


n = int(input())
s = list(map(int, input().split()))
(a, b) = (-1, 188888)
for t in range(1, 101):
	mi = 0
	for i in range(n):
		mi += min(abs(s[i] - t), abs(s[i] - t - 1), abs(s[i] - t + 1))
	if b > mi:
		(a, b) = (t, mi)
print(a, b)


n = int(input())
A = [int(x) for x in input().split()]

def f(A, t):
	S = 0
	for a in A:
		if abs(a - t) == 0:
			S += 0
		else:
			S += abs(a - t) - 1
	return S
t = min(range(1, 101), key=lambda x: f(A, x))
print(t, f(A, t))


n = int(input())
a = [int(s) for s in input().split()]
t = 0
min_s = 1000000
max_el = 0
for i in a:
	if i > max_el:
		max_el = i
for i in range(1, max_el + 1):
	s = 0
	for el in a:
		if el != i:
			s += abs(el - i) - 1
	if s < min_s:
		min_s = s
		t = i
print(t, min_s)


n = int(input())
arr = list(map(int, input().split()))
T = 1
min_value = 100 * 1000
for t in range(1, max(arr) + 1):
	temp = 0
	for i in arr:
		if i < t:
			temp += abs(i - t + 1)
		elif i > t:
			temp += abs(t + 1 - i)
	if temp < min_value:
		min_value = temp
		T = t
print(T, min_value)


n = int(input())
s = input()
s = s.split()
for i in range(n):
	s[i] = int(s[i])
answert = 0
answersum = 100000
for t in range(1, 100):
	sum = 0
	for j in range(n):
		if t - s[j] >= 1:
			sum += t - 1 - s[j]
		elif s[j] - t >= 1:
			sum += s[j] - 1 - t
	if sum < answersum:
		answersum = sum
		answert = t
print(answert, answersum)


n = int(input())
arr = [int(i) for i in input().split()]
m = 10 ** 9
c = 0
for i in range(1, 101):
	ans = 0
	for j in arr:
		if abs(i - j) > 1:
			ans += abs(i - j) - 1
	if ans < m:
		m = ans
		c = i
print(c, m)


n = int(input())
stick = list(map(int, input().split()))
d = []
for i in range(1, max(stick) + 1):
	s = 0
	for j in stick:
		s += min(abs(i - 1 - j), abs(i - j), abs(i + 1 - j))
	d.append((s, i))
d.sort()
print(d[0][1], d[0][0])


n = int(input())
a = list(map(int, input().split()))
b = []
maxi = 1000000
for i in range(max(a) + 1):
	count = 0
	for j in a:
		if j > i + 2:
			count += abs(j - (i + 2))
		elif j < i:
			count += abs(i - j)
	if count < maxi:
		maxi = count
	else:
		print(i, maxi)
		break


n = int(input())
A = list(map(int, input().split()))
m = 100000000000000
t = 1
for i in range(1, 101):
	x = m
	s = 0
	for j in range(0, n):
		if abs(i - A[j]) > 1:
			s += abs(i - A[j]) - 1
		else:
			continue
	m = min(m, s)
	if m != x:
		t = i
print(t, m)


import math

def abs(x):
	return int(math.fabs(x))
n = int(input())
a = list(map(int, input().strip().split()))

def get_cost(a, t):
	cost = 0
	for elem in a:
		if elem < t - 1:
			cost += t - 1 - elem
		elif elem > t + 1:
			cost += elem - t - 1
	return cost
mean = int(sum(a) / len(a))
possible_ts = list()
if mean > 1:
	possible_ts = [mean - 1, mean, mean + 1]
else:
	possible_ts = [mean, mean + 1]
possible_ts = list(range(1, max(a) + 1, 1))
possible_costs = [get_cost(a, t) for t in possible_ts]
min_cost = min(possible_costs)
min_idx = possible_costs.index(min_cost)
min_t = possible_ts[min_idx]
print('{} {}'.format(min_t, min_cost))


n = int(input())
a = [*map(int, input().split())]
mcost = 10 ** 8
ans = 0
for i in range(1, 101):
	tcost = 0
	for j in range(n):
		if a[j] > i:
			d = abs(a[j] - (i + 1))
		elif a[j] < i:
			d = abs(a[j] - (i - 1))
		else:
			d = 0
		tcost += d
	if tcost < mcost:
		(mcost, ans) = (tcost, i)
print(ans, mcost)


n = int(input())
a = [*map(int, input().split())]
a = sorted(a)
m = 100000
t = 0
for i in range(a[n - 1]):
	s = 0
	for b in a:
		if abs(b - i) <= 1:
			continue
		else:
			s += abs(b - i) - 1
	if s < m:
		m = s
		t = i
if t == 0:
	t = 1
print(t, m)


n = int(input())
a = list(map(int, input().split()))
optimal_t = 0
min_changes = 1000000
for t in range(1, 100 + 1):
	changes = 0
	for ai in a:
		if abs(ai - t) > 1:
			changes += abs(ai - t) - 1
	if changes < min_changes:
		min_changes = changes
		optimal_t = t
print(optimal_t, min_changes)


import sys, math, string
input = sys.stdin.readline
L = lambda : list(map(int, input().split()))
Ls = lambda : list(input().split())
M = lambda : map(int, input().split())
n = int(input())
l = L()
m = 9999999
a = 0
for i in range(1, 1000):
	t = 0
	for j in range(n):
		if l[j] > i:
			t = t + l[j] - i - 1
		elif l[j] < i:
			t = t + i - l[j] - 1
	if t < m:
		m = t
		a = i
print(a, m)


n = int(input())
s = [int(i) for i in input().split()]
cnt = 0
mini = float('inf')
for i in range(1, max(s) + 1):
	cnt = 0
	for j in range(n):
		if abs(i - s[j]) > 1:
			cnt += abs(i - s[j]) - 1
	if cnt < mini:
		a = i
		mini = cnt
print(a, mini)


n = int(input())
arr = list(map(int, input().split()))
arr.sort()
a = []
for t in range(1, 101):
	tot = 0
	for item in arr:
		if abs(item - t) >= 1:
			tot += abs(item - t) - 1
	a.append((tot, t))
a.sort()
print(a[0][1], a[0][0])


n = int(input())
a = list(map(int, input().split()))
ans = 1e+18
ans_t = -1
for t in range(1, 101):
	curr = 0
	for el in a:
		if el > t:
			curr += el - (t + 1)
		elif el < t:
			curr += t - 1 - el
	if curr < ans:
		ans = curr
		ans_t = t
print(ans_t, ans)


n = int(input())
A = list(map(int, input().split()))
(ft, fc) = (None, None)
for t in range(1, 101):
	tc = 0
	for a in A:
		tc += max(0, abs(a - t) - 1)
	if not ft or fc > tc:
		(ft, fc) = (t, tc)
print(str(ft) + ' ' + str(fc))


n = int(input())
a = list(map(int, input().split()))
min1 = 1000001
c = 0
for i in range(1, 101):
	sum1 = 0
	for j in a:
		if abs(j - i) <= 1:
			continue
		sum1 = sum1 + abs(j - i) - 1
	if min1 > sum1:
		min1 = sum1
		c = i
print(c, min1)


m = 1000000
k = 0
s = 0
n = int(input())
L = [int(i) for i in input().split()]
for i in range(1, 101):
	s = 0
	for j in L:
		if i != j:
			s += abs(i - j) - 1
	if s < m:
		k = i
		m = s
print(k, m)


import math
n = int(input())
l = input().split()
l = list(map(int, l))
l.sort()
x = max(l)
c = 0
costs = []
for i in range(1, x + 1):
	c = 0
	for j in l:
		c = c + abs(i - j)
		if abs(i - j) != 0:
			c = c - 1
	costs.append(c)
y = min(costs)
ans = costs.index(y)
print(ans + 1, y)


from math import *
n = int(input())
a = sorted(list(map(int, input().split())))
mt = 1
ms = 0
for i in a:
	if i > mt:
		ms += i - mt - 1
	elif i < mt:
		ms += mt - i - 1
for t in range(2, 101):
	s = 0
	for i in a:
		if i > t:
			s += i - t - 1
		elif i < t:
			s += t - i - 1
	if s < ms:
		ms = s
		mt = t
print(mt, ms)


n = int(input())
arr = list(map(int, input().split()))
cost_min = sum(arr)
hold = 0
for t in range(1, max(arr) + 1):
	target = t
	cost = 0
	for j in arr:
		if j < target - 1 or j > target + 1:
			if j > target:
				cost += j - target - 1
			if j < target:
				cost += target - 1 - j
	if cost < cost_min:
		cost_min = cost
		hold = target
print(hold, cost_min)


import math
n = int(input())
a = list(map(int, input().split()))
sm = 100000000
t = 100
for x in range(1, 200):
	s = 0
	for i in range(len(a)):
		if abs(a[i] - x) > 1:
			s = s + abs(a[i] - x) - 1
	if sm > s:
		t = x
		sm = s
print(t, sm)


import math
n = int(input())
a = list(map(int, input().split()))
x = min(a)
y = max(a)
ans1 = 10 ** 9
ans2 = 10 ** 9
for j in range(1, 100):
	ans = 0
	for i in range(n):
		if a[i] > j + 1:
			ans = ans + a[i] - j - 1
		elif a[i] < j - 1:
			ans = ans + j - 1 - a[i]
	if ans < ans2:
		ans2 = ans
		ans1 = j
print(ans1, ans2)


n = int(input())
l = list(map(int, input().split()))
min1 = float('inf')
t = 0
for i in range(1, 101):
	sum1 = 0
	for j in l:
		sum1 = sum1 + min(abs(j - i - 1), abs(j - i + 1), abs(j - i))
	if min1 > sum1:
		t = i
		min1 = sum1
print(t, min1)


def fastio():
	import sys
	from io import StringIO
	from atexit import register
	global input
	sys.stdin = StringIO(sys.stdin.read())
	input = lambda : sys.stdin.readline().rstrip('\r\n')
	sys.stdout = StringIO()
	register(lambda : sys.__stdout__.write(sys.stdout.getvalue()))
fastio()
MOD = 10 ** 9 + 7
I = lambda : list(map(int, input().split()))
(n,) = I()
l = I()
tt = 1
res = MOD
for t in range(1, 101):
	ans = 0
	for i in l:
		if abs(i - t) <= 1:
			continue
		if i < t:
			ans += t - i - 1
		else:
			ans += i - t - 1
	if ans < res:
		res = ans
		tt = t
print(tt, res)


n = int(input())
arr = list(map(int, input().strip().split()))
ans = [0] * 100
for a in range(1, 101):
	s = 0
	for x in range(n):
		curr = abs(arr[x] - a)
		if curr > 1:
			s += curr - 1
	ans[a - 1] = s
res = min(ans)
t = ans.index(res) + 1
print(t, res)


n = int(input())
a = [int(x) for x in input().split()]
b = []
for x in range(1, 101):
	c = 0
	for i in range(n):
		c += min(abs(x - a[i] - 1), abs(x - a[i] + 1), abs(x - a[i]))
	b.append(c)
print(b.index(min(b)) + 1, min(b))


def read_nums():
	return [int(x) for x in input().split()]

def compute_min_cost(t, nums):
	res = 0
	for num in nums:
		if abs(t - num) <= 1:
			continue
		res += abs(num - t) - 1
	return res

def main():
	_ = read_nums()
	costs = []
	nums = read_nums()
	for t in range(1, 101):
		min_cost = compute_min_cost(t, nums)
		costs.append((t, min_cost))
	(t, cost) = sorted(costs, key=lambda x: x[1])[0]
	print(t, cost)

def __starting_point():
	main()
__starting_point()


import bisect

def solve(xs):
	xs = sorted(xs)
	sums = [0]
	for x in xs:
		sums.append(sums[-1] + x)
	t = None
	best = float('inf')
	for mid in range(1, 100 + 1):
		lower_end = bisect.bisect_left(xs, mid - 1)
		upper_begin = bisect.bisect_right(xs, mid + 1, lower_end)
		lower_cost = (mid - 1) * lower_end - sums[lower_end]
		upper_cost = sums[-1] - sums[upper_begin] - (mid + 1) * (len(xs) - upper_begin)
		cost = lower_cost + upper_cost
		if cost < best:
			best = cost
			t = mid
	return (t, best)
n = int(input())
xs = list(map(int, input().split()))[:n]
(t, cost) = solve(xs)
print(t, cost)


def sticks(a):
	MIN_VAL = 1000 * 100
	T = 1
	for t in range(1, max(a) + 1):
		temp = 0
		for i in a:
			if i < t:
				temp += abs(t - 1 - i)
			elif i > t:
				temp += abs(i - t - 1)
		if temp < MIN_VAL:
			MIN_VAL = temp
			T = t
	print(T, MIN_VAL)
n = int(input())
a = list(map(int, input().split()))
sticks(a)


n = int(input())
input1 = input().split(' ')
data = []
maximum = -1
for i in range(n):
	data.append(int(input1[i]))
	if data[i] > maximum:
		maximum = data[i]
min_t = -1
min_cost = 100000
for i in range(1, maximum + 1):
	acu = 0
	for j in range(n):
		acu += abs(data[j] - i) - 1 if abs(data[j] - i) > 1 else 0
	if acu < min_cost:
		min_cost = acu
		min_t = i
print('%d %d' % (min_t, min_cost))


a = int(input())
b = list(map(int, input().split()))
b.sort()
t = 0
c = []
for i in range(1, b[a - 1] + 1):
	t = 0
	for j in b:
		if j != i:
			t = t + abs(j - i) - 1
		else:
			t = t + abs(j - i)
	c.append([t, i])
c.sort()
print(c[0][1], c[0][0])


n = int(input())
ain = [int(x) for x in input().split()]
ans = []
for t in range(101):
	sum = 0
	for i in ain:
		sum += max(0, abs(t - i) - 1)
	ans.append(sum)
t = ans[1:].index(min(ans)) + 1
print(t, ans[t])


n = int(input())
mas = list(map(int, input().split()))
ans = []
for t in range(1, 101):
	a = 0
	for i in mas:
		if i > t:
			a += i - t - 1
		elif i < t:
			a += t - i - 1
	ans.append([a, t])
print(min(ans)[1], min(ans)[0])


n = int(input())
m = [int(i) for i in input().split()]
res = 10000000
res1 = 0
for i in range(1, 101):
	bfsm = 0
	for j in range(len(m)):
		if m[j] > i:
			bfsm += m[j] - i - 1
		elif m[j] < i:
			bfsm += i - 1 - m[j]
	if bfsm < res:
		res = bfsm
		res1 = i
print(res1, res)


n = int(input())
mini = 1000000000000000
p = input().rstrip().split(' ')
for i in range(1, 500):
	ans = 0
	for j in range(0, len(p)):
		A = i
		B = int(p[j])
		if abs(B - A) <= 1:
			continue
		else:
			C = abs(B - A) - 1
			ans += C
	if ans < mini:
		mini = ans
		G = i
print(G, mini)


import math

def minStepsForANumber(arr, n):
	res = 0
	for i in arr:
		if i > n:
			res += i - n - 1
		if i < n:
			res += n - i - 1
	return res
n = int(input())
arr = list(map(int, input().split()))
minT = None
minSteps = math.inf
for i in range(1, 101):
	stepsReq = minStepsForANumber(arr, i)
	if stepsReq < minSteps:
		minT = i
		minSteps = stepsReq
print(minT, minSteps)


from sys import stdin, stdout

def main():
	n = int(stdin.readline())
	vals = [int(i) for i in stdin.readline().split()]
	best_t = 1
	best_c = 1000000
	for t in range(1, 101):
		cost = 0
		for i in range(n):
			v = vals[i]
			if v < t - 1:
				cost += abs(v - (t - 1))
			elif v > t + 1:
				cost += abs(v - (t + 1))
		if cost < best_c:
			best_t = t
			best_c = cost
	stdout.write(str(best_t) + ' ' + str(best_c) + '\n')
main()


n = int(input())
a = list(map(int, input().split()))
s = 123454321
for t in range(1, 101):
	res = 0
	for i in range(0, n):
		res += min(abs(t - 1 - a[i]), abs(t + 1 - a[i]), abs(t - a[i]))
	if s > res:
		s = res
		t1 = t
print(t1, s)


n = int(input())
a = list(map(int, input().split()))
ans = 234567891
ind = 0
for i in range(1, 101):
	temp = 0
	for j in range(0, n):
		b = abs(a[j] - i)
		if b > 0:
			temp += b - 1
	if temp < ans:
		ans = temp
		ind = i
print(ind, ans)


import sys
n = int(input())
l1 = list(map(int, input().split()))
l2 = [0] * 101
l2[0] = sys.maxsize
for i in range(1, 101):
	cost = 0
	for j in range(n):
		if abs(l1[j] - i) > 1:
			cost += abs(l1[j] - i) - 1
	l2[i] = cost
x = min(l2[1:len(l2)])
print(l2.index(x), x)


n = int(input())
ar = list(map(int, input().split()))

def f(i):
	ans = 0
	for e in ar:
		if e == i:
			continue
		else:
			ans += abs(e - i) - 1
	return ans
a = float('inf')
b = 0
for x in range(1, 1001):
	if f(x) < a:
		a = f(x)
		b = x
print(b, a)


from math import inf

def cost(arr, t):
	c = 0
	for ele in arr:
		if abs(ele - t) > 1:
			if ele > t:
				c += ele - (t + 1)
			else:
				c += t - (ele + 1)
	return c
n = int(input().strip())
arr = list(map(int, input().strip().split()))
maxi = max(arr)
best_t = 0
min_cost = inf
for t in range(1, maxi + 1):
	curr_cost = cost(arr, t)
	if curr_cost < min_cost:
		min_cost = curr_cost
		best_t = t
print(best_t, min_cost)


n = int(input())
l = list(map(int, input().split()))
maxx = 10000000000
cur = 0
for i in range(1, 101):
	now = 0
	for j in range(n):
		if l[j] < i:
			now += i - l[j] - 1
		elif l[j] > i:
			now += l[j] - i - 1
	if now < maxx:
		maxx = now
		cur = i
print(cur, maxx)


a = int(input())
b = list(map(int, input().split()))
t = sum(b)
x = b[:]
y = b[:]
z = b[:]
j = []
k = []
for u in range(1, 101):
	score_x = 0
	for num in x:
		if abs(num - u) > 1:
			score_x += min(abs(num - u), abs(num - (u + 1)), abs(num - (u - 1)))
	j.append((score_x, u))
j.sort()
k.append(j[0][1])
k.append(j[0][0])
print(*k)


n = int(input())
l = [int(x) for x in input().split()]
value = 0
inc = 10 ** 10
for t in range(1, 105):
	g = 0
	for i in range(n):
		g += max(0, abs(l[i] - t) - 1)
	if g < inc:
		inc = g
		value = t
print(value, inc)


n = int(input())
a = list(map(int, input().split()))
m = 102 * (n + 1)
for i in range(1, 101):
	k = i
	ans = 0
	for j in range(n):
		if k < a[j]:
			ans += a[j] - (k + 1)
		elif k == a[j]:
			ans += 0
		else:
			ans += k - 1 - a[j]
	if m > ans:
		m = ans
		t = k
print(t, m)


n = int(input())
a = list(map(int, input().split()))
ans = 10 ** 9
fin = 0
for i in range(1, 101):
	x = 0
	for j in range(n):
		if i > a[j] + 1:
			x += i - (a[j] + 1)
		elif i < a[j] - 1:
			x += a[j] - 1 - i
	if x < ans:
		fin = i
		ans = x
print(fin, ans)


n = int(input())
x = list(map(int, input().split()))
t = 1
min_sum = 10 ** 10
min_t = 0
for i in range(max(x)):
	total_sum = 0
	for j in range(n):
		if abs(x[j] - t) > 1:
			total_sum += abs(x[j] - t) - 1
	if total_sum < min_sum:
		min_t = t
		min_sum = total_sum
	t += 1
print(min_t, min_sum)


import math

def ii():
	return int(input())

def mi():
	return map(int, input().split())

def li():
	return list(mi())
n = ii()
a = li()
cost = 10000000
index = -1
for i in range(1, 101):
	c = 0
	for j in range(n):
		if i > a[j] + 1:
			c += i - a[j] - 1
		elif i < a[j] - 1:
			c += a[j] - 1 - i
	if cost > c:
		cost = c
		index = i
print(str(index) + ' ' + str(cost))


n = int(input())
a = [int(v) for v in input().split()]
a.sort()

def cost1(v, t):
	if v < t - 1:
		return t - 1 - v
	elif v > t + 1:
		return v - (t + 1)
	else:
		return 0
best_t = None
best_cost = 9999999999999
for t in range(1, 101):
	cost = sum((cost1(v, t) for v in a))
	if cost < best_cost:
		best_cost = cost
		best_t = t
print(best_t, best_cost)


n = int(input())
arr = [int(i) for i in input().split()]
cost = 10000000
tmp = 0
for t in range(1, 101):
	c = 0
	count = 0
	for i in range(len(arr)):
		c += min(min(abs(arr[i] - t), abs(arr[i] - t - 1)), abs(arr[i] - t + 1))
	if c < cost:
		cost = c
		tmp = t
print(tmp, cost, sep=' ')


from sys import stdin, stdout
from math import sin, tan, cos, pi, atan2, sqrt, acos, atan, factorial
from random import randint
n = int(stdin.readline())
vl = list(map(int, stdin.readline().split()))
ans = float('inf')
c = 0
for v in range(1, 101):
	cnt = 0
	for i in range(n):
		if vl[i] >= v:
			cnt += max(vl[i] - v - 1, 0)
		else:
			cnt += max(v - vl[i] - 1, 0)
	if cnt < ans:
		c = v
	ans = min(ans, cnt)
stdout.write(str(c) + ' ' + str(ans))


n = int(input())
a = list(map(int, input().split()))
(t, ans, p) = (1, 1, float('inf'))
while t <= 100:
	summ = 0
	for item in a:
		cur = 0
		if item > t + 1:
			cur = item - (t + 1)
		elif item < t - 1:
			cur = t - 1 - item
		summ += cur
	if summ < p:
		p = summ
		ans = t
	t += 1
print(ans, p)


from sys import stdin
n = int(stdin.readline().strip())
s = list(map(int, stdin.readline().strip().split()))
s.sort()
ans = 10 ** 20
t1 = -1
for t in range(1, 101):
	aux1 = 0
	for j in range(n):
		aux = 102
		aux = min(aux, abs(1 + t - s[j]))
		aux = min(aux, abs(t - 1 - s[j]))
		aux = min(aux, abs(t - s[j]))
		aux1 += aux
	if aux1 < ans:
		ans = aux1
		t1 = t
print(t1, ans)


n = int(input())
l = list(map(int, input().split()))
m = 10000000
ans = 1
for i in range(1, 101):
	s = 0
	for j in l:
		s += max(0, abs(j - i) - 1)
	if s < m:
		m = s
		ans = i
print(ans, m)


n = int(input())
s = input()
s = [int(x) for x in s.split()]
ans = 1000000
for t in range(1, 101):
	summ_cost = 0
	for i in range(len(s)):
		if s[i] > t:
			b = s[i] - (t + 1)
		elif s[i] < t:
			b = t - 1 - s[i]
		else:
			b = 0
		summ_cost += b
	if summ_cost < ans:
		ans = summ_cost
		ans_t = t
print(ans_t, ans)


n = int(input())
a = [int(i) for i in input().split()]
mi = 10 ** 8
x = -1
for i in range(1, 111):
	s = 0
	for j in range(n):
		if not i - 1 <= a[j] <= i + 1:
			if a[j] < i - 1:
				z = i - 1 - a[j]
			else:
				z = a[j] - i - 1
			s += z
	if s < mi:
		mi = s
		x = i
print(x, mi)


n = int(input())
a = list(map(int, input().split()))
costs = [sum((max(abs(a[i] - t) - 1, 0) for i in range(n))) for t in range(1, 101)]
optimal_cost = min(costs)
print(costs.index(optimal_cost) + 1, optimal_cost)


import sys
import math
import itertools
import functools
import collections
import operator

def ii():
	return int(input())

def mi():
	return map(int, input().split())

def li():
	return list(map(int, input().split()))

def lcm(a, b):
	return abs(a * b) // math.gcd(a, b)

def wr(arr):
	return ' '.join(map(str, arr))

def revn(n):
	return str(n)[::-1]

def dd():
	return collections.defaultdict(int)

def ddl():
	return collections.defaultdict(list)

def sieve(n):
	if n < 2:
		return list()
	prime = [True for _ in range(n + 1)]
	p = 3
	while p * p <= n:
		if prime[p]:
			for i in range(p * 2, n + 1, p):
				prime[i] = False
		p += 2
	r = [2]
	for p in range(3, n + 1, 2):
		if prime[p]:
			r.append(p)
	return r

def divs(n, start=1):
	r = []
	for i in range(start, int(math.sqrt(n) + 1)):
		if n % i == 0:
			if n / i == i:
				r.append(i)
			else:
				r.extend([i, n // i])
	return r

def divn(n, primes):
	divs_number = 1
	for i in primes:
		if n == 1:
			return divs_number
		t = 1
		while n % i == 0:
			t += 1
			n //= i
		divs_number *= t

def prime(n):
	if n == 2:
		return True
	if n % 2 == 0 or n <= 1:
		return False
	sqr = int(math.sqrt(n)) + 1
	for d in range(3, sqr, 2):
		if n % d == 0:
			return False
	return True

def convn(number, base):
	newnumber = 0
	while number > 0:
		newnumber += number % base
		number //= base
	return newnumber

def cdiv(n, k):
	return n // k + (n % k != 0)
n = ii()
a = li()
ans = 10 ** 6
t = 0
for i in range(1, 101, 1):
	ts = 0
	for j in range(n):
		if a[j] < i:
			ts += i - 1 - a[j]
		elif a[j] > i:
			ts += a[j] - i - 1
	if ts < ans:
		t = i
		ans = ts
print(t, ans)


n = int(input())
a = [int(i) for i in input().split()]
min_s = 1000000
for t in range(1, 101):
	s = 0
	for i in range(n):
		s += min(abs(a[i] - t - 1), abs(a[i] - t), abs(a[i] - t + 1))
	if s < min_s:
		min_s = s
		min_t = t
print(min_t, min_s)


n = int(input())
l = list(map(int, input().split()))
m = max(l)
min = 100000000
for p in range(1, m + 1):
	sum = 0
	for i in l:
		if i < p:
			sum += p - i - 1
		elif i > p:
			sum += i - p - 1
	if sum < min:
		min = sum
		p1 = p
print(p1, min)


n = int(input())
a = list(map(int, input().split()))
ans = 10 ** 8
ansi = 0
for i in range(1, 101):
	tmp = sum((min(abs(i - t - 1), abs(i - t + 1), abs(i - t)) for t in a))
	if tmp < ans:
		ans = tmp
		ansi = i
print(ansi, ans)


n = int(input())
data = [int(x) for x in input().split()]
data.sort()
pos = len(data) // 2
(val, cost) = (0, 1000000000000)
for q in range(1, 110):
	temp_val = q
	temp_cost = 0
	for w in range(n):
		if data[w] > q + 1:
			temp_cost += data[w] - q - 1
		elif data[w] < q - 1:
			temp_cost += q - 1 - data[w]
	if temp_cost < cost:
		cost = temp_cost
		val = q
print(val, cost)


import math
n = int(input())
a = [int(i) for i in input().split()]
max = 10 ** 9
flag = 0
for i in range(1, 101):
	sum = 0
	for j in range(0, len(a)):
		e = abs(a[j] - i) - 1
		if e <= 0:
			e = 0
		sum = sum + e
	if sum < max:
		max = sum
		flag = i
print(flag, max)


__author__ = 'Esfandiar'
n = int(input())
a = sorted(list(map(int, input().split())))
ans = 0
M = 100000000000.0
for t in range(1, 101):
	Cost = 0
	for j in range(n):
		Cost += max(abs(t - a[j]) - 1, 0)
	if Cost < M:
		M = Cost
		ans = t
print(ans, M)


a = int(input())
sticks = list(map(int, input().split()))
minn = []
for t in range(1, 101):
	minn.append(0)
	for a in sticks:
		p = abs(a - t)
		if p != 0:
			p -= 1
		minn[t - 1] += p
print(minn.index(min(minn)) + 1, min(minn))


n = int(input())
a = list(map(int, input().split()))
ans = None
for t in range(1, 1001):
	anss = 0
	for i in a:
		anss += min(abs(i - t), abs(i - (t - 1)), abs(i - (t + 1)))
	if ans is None:
		ans = [anss, t]
	elif anss < ans[0]:
		ans = [anss, t]
print(*ans[::-1])


import math
from decimal import Decimal
import heapq

def na():
	n = int(input())
	b = [int(x) for x in input().split()]
	return (n, b)

def nab():
	n = int(input())
	b = [int(x) for x in input().split()]
	c = [int(x) for x in input().split()]
	return (n, b, c)

def dv():
	(n, m) = map(int, input().split())
	return (n, m)

def dva():
	(n, m) = map(int, input().split())
	a = [int(x) for x in input().split()]
	b = [int(x) for x in input().split()]
	return (n, m, b)

def eratosthenes(n):
	sieve = list(range(n + 1))
	for i in sieve:
		if i > 1:
			for j in range(i + i, len(sieve), i):
				sieve[j] = 0
	return sorted(set(sieve))

def nm():
	n = int(input())
	b = [int(x) for x in input().split()]
	m = int(input())
	c = [int(x) for x in input().split()]
	return (n, b, m, c)

def dvs():
	n = int(input())
	m = int(input())
	return (n, m)
(n, a) = na()
mx = 999999999999999999999
ans = 0
for t in range(1, 151):
	tc = 0
	for i in range(n):
		if a[i] == t:
			continue
		else:
			tc += abs(a[i] - t) - 1
	if tc < mx:
		mx = tc
		ans = t
print(ans, mx)


n = int(input())
a = [int(x) for x in input().split()]
min_cost = 10 ** 9
best_t = 10 ** 9
for t in range(1, 101):
	cost = 0
	for l in a:
		cost += max(abs(l - t) - 1, 0)
	if cost < min_cost:
		min_cost = cost
		best_t = t
print(best_t, min_cost)


input()
a = [*map(int, input().split())]
(c, t) = min(((sum((max(0, abs(t - x) - 1) for x in a)), t) for t in range(1, max(a) + 1)))
print(t, c)


def salem(lst):
	(maximum, t) = (10 ** 9, 0)
	for i in range(1, 100):
		current = 0
		for j in range(len(lst)):
			current += max(0, abs(i - lst[j]) - 1)
		if current < maximum:
			(maximum, t) = (current, i)
	return (t, maximum)
n = int(input())
a = [int(i) for i in input().split()]
print(*salem(a))


import sys
import math
fileoperation = 0
if fileoperation:
	orig_stdout = sys.stdout
	orig_stdin = sys.stdin
	inputfile = open('W:/Competitive Programming/input.txt', 'r')
	outputfile = open('W:/Competitive Programming/output.txt', 'w')
	sys.stdin = inputfile
	sys.stdout = outputfile
mod = 1000000007

def nospace(l):
	ans = ''.join((str(i) for i in l))
	return ans
t = 1
for tt in range(t):
	n = int(input())
	a = list(map(int, sys.stdin.readline().split(' ')))
	cost = mod
	ans = -1
	for i in range(1, 101):
		c = 0
		for j in range(n):
			c += min(abs(a[j] - i), abs(a[j] - i - 1), abs(a[j] - i + 1))
		if c < cost:
			ans = i
			cost = c
	print(ans, cost)
if fileoperation:
	sys.stdout = orig_stdout
	sys.stdin = orig_stdin
	inputfile.close()
	outputfile.close()


n = int(input())
s = list(map(int, input().split()))
d = []
for i in range(1, 101):
	c = 0
	for k in s:
		if k > i + 1:
			c = c + k - i - 1
		elif k < i - 1:
			c = c + abs(k - i + 1)
	d.append(c)
l = min(d)
for i in range(len(d)):
	if d[i] == l:
		print(i + 1, l)
		break


n = int(input())
a = sorted(list(map(int, input().split())))
tempt = 1
t = 1
cost = 9223372036854775807
while tempt <= a[-1]:
	tempCost = 0
	for i in range(n):
		if a[i] == tempt or a[i] == tempt + 1 or a[i] == tempt - 1:
			tempCost += 0
		else:
			tempCost += abs(a[i] - tempt) - 1
	if tempCost < cost:
		cost = tempCost
		t = tempt
	tempt += 1
print(t, cost)


n = int(input())
a = list(map(int, input().split()))
min_cost = 9999999999999
new_t = 0
for t in range(1, 101):
	cost = 0
	for j in range(n):
		if abs(a[j] - t) <= 1:
			continue
		else:
			cost += abs(a[j] - t) - 1
	if cost < min_cost:
		min_cost = cost
		new_t = t
print(new_t, min_cost)


n = int(input())
arr = list(map(int, input().split()))
d = {}
for i in range(1, 100 + 1):
	sm = 0
	for j in range(n):
		if arr[j] == i or abs(arr[j] - i) <= 1:
			continue
		elif arr[j] > i:
			x = abs(arr[j] - i)
			x -= 1
			sm += x
		elif arr[j] < i:
			x = abs(arr[j] - i)
			x -= 1
			sm += x
	d[i] = sm
r1 = min(d.values())
for (i, j) in d.items():
	if j == r1:
		print(i, j)
		break


from sys import stdin, stdout, maxsize

def main():
	stdin.readline()
	lst = [int(x) for x in stdin.readline().split()]
	(min_sum, average) = (maxsize, 0)
	for i in range(1, 101):
		summ = 0
		for item in lst:
			summ += min(abs(item - i + 1), min(abs(item - i - 1), abs(item - i)))
		if summ < min_sum:
			min_sum = summ
			average = i
	stdout.write(str(average) + ' ' + str(min_sum))
main()


n = int(input())
sticks = list(map(int, input().split()))
minimal = 100000
min_len = 100000
for i in range(1, 101):
	m = 0
	for stick in sticks:
		if stick - i < -1 or stick - i > 1:
			m += abs(stick - i) - 1
	if m < minimal:
		minimal = m
		min_len = i
print(min_len, minimal)


import operator as op
import re
import sys
from bisect import bisect, bisect_left, insort, insort_left
from collections import Counter, defaultdict, deque
from copy import deepcopy
from decimal import Decimal
from functools import reduce
from itertools import accumulate, combinations, combinations_with_replacement, groupby, permutations, product
from math import acos, asin, atan, ceil, cos, degrees, factorial, gcd, hypot, log2, pi, radians, sin, sqrt, tan
from operator import itemgetter, mul
from string import ascii_lowercase, ascii_uppercase, digits

def inp():
	return int(input())

def inlist():
	return list(map(int, input().split()))

def instr():
	s = input()
	return list(s[:len(s)])

def invr():
	return map(int, input().split())

def def_value():
	return 0

def time_lagbe(n, k, t):
	if n == 0:
		return 0
	if k > n:
		return t
	time1 = n // k * t + n % k * t
	return time1
n = inp()
a = inlist()
minCost = 10000000
minT = -1
for t in range(1, 101):
	cost = 0
	for i in range(n):
		if a[i] < t:
			cost += t - (a[i] + 1)
		elif a[i] > t:
			cost += a[i] - (t + 1)
	if cost < minCost:
		minCost = cost
		minT = t
print(minT, minCost)


n = int(input())
l = list(map(int, input().split()))
ka = 10 ** 9
x = 0
for i in range(1, 101):
	s = 0
	for j in range(n):
		s += max(abs(l[j] - i) - 1, 0)
	if s < ka:
		ka = s
		x = i
print(x, ka)


n = int(input())
ch = input()
L1 = ch.split()
L = []
for i in range(n):
	L.append(int(L1[i]))
L.sort()
cost = 0
for i in range(n):
	if abs(L[i]) > 1:
		cost = cost + abs(L[i]) - 1
m = cost
t = L[n - 1]
for j in range(L[n - 1]):
	cost = 0
	for i in range(n):
		if abs(L[i] - j) > 1:
			cost = cost + abs(L[i] - j) - 1
	if cost < m:
		m = cost
		t = j
print(str(t) + ' ' + str(m))


n = int(input())
a = list(map(int, input().split(' ')))
t = 1
m = 10000000000
while t < 105:
	count = 0
	for i in range(n):
		if a[i] > t:
			count += a[i] - 1 - t
		elif a[i] == t:
			count += 0
		else:
			count += t - 1 - a[i]
	if count < m:
		m = count
		k = t
	t += 1
print(k, m)


n = int(input())
arr = list(map(int, input().split()))
min_c = 1000000000.0
tt = -1
for t in range(1, 101):
	new_arr = arr.copy()
	cost = 0
	for i in range(n):
		cost += min(abs(arr[i] - t + 1), abs(arr[i] - t), abs(arr[i] - t - 1))
	if cost < min_c:
		min_c = cost
		tt = t
print(tt, min_c)


def _main():
	ts = input()
	a = input().split(' ')
	mi: int = 10000000000.0
	t: int = 1
	mt: int = 1
	a.sort()
	while mt <= 100:
		sum: int = 0
		for x in a:
			if int(x) < mt:
				sum += abs(int(x) + 1 - mt)
			elif int(x) > mt:
				sum += abs(int(x) - 1 - mt)
		if sum < mi:
			mi = sum
			t = mt
		mt += 1
	print(str(t) + ' ' + str(mi))
_main()


n = int(input())
a = list(map(int, input().split()))
tans = 0
ans = 10 ** 9
for i in range(1, 100):
	t = 0
	for j in a:
		if j <= i + 1 and j >= i - 1:
			continue
		if j < i - 1:
			t += abs(j - (i - 1))
		if j > i + 1:
			t += abs(j - (i + 1))
	if ans > t:
		ans = t
		tans = i
print(tans, ans)


n = int(input())
a = list(map(int, input().split()))
t = max(a)
s = []
for j in range(1, t + 1):
	m = 0
	for i in range(n):
		m += min(abs(a[i] - j), abs(a[i] - 1 - j), abs(j - 1 - a[i]))
	s.append(m)
f = s.index(min(s))
print(f + 1, s[f])


a = int(input())
p = [int(i) for i in input().split()]
m = 99999999999999999999
l = 0
for i in range(1, 101):
	t = 0
	for j in p:
		if abs(j - i) > 1:
			t += abs(j - i) - 1
	if t < m:
		m = t
		l = i
print(l, m)


n = int(input())
a = [int(x) for x in input().split(' ')]
x = sum(a) // n
m = float('inf')
for i in range(1, max(a) + 1):
	s = 0
	for c in a:
		s += min(abs(c - (i - 1)), abs(c - i), abs(c - (i + 1)))
	if s < m:
		y = i
		m = min(s, m)
print(y, m)


import os
import sys
import math
import heapq
from decimal import *
from io import BytesIO, IOBase
from collections import defaultdict, deque

def r():
	return int(input())

def rm():
	return map(int, input().split())

def rl():
	return list(map(int, input().split()))
n = r()
a = rl()
res = 0
maxi = math.inf
for i in range(1, 102):
	cal = 0
	for j in a:
		cal += min([abs(j - i), abs(j - i - 1), abs(j - i + 1)])
	if cal < maxi:
		maxi = cal
		res = i
print(res, maxi)


n = int(input())
l = list(map(int, input().split()))
max1 = 99999
for i in range(1, 101):
	sum1 = 0
	for j in range(len(l)):
		if l[j] > i:
			sum1 = sum1 + abs(l[j] - i - 1)
		elif l[j] < i:
			sum1 = sum1 + abs(l[j] + 1 - i)
		else:
			sum1 = sum1 + 0
	if max1 > sum1:
		max1 = sum1
		k = i
print(k, max1, end=' ')


n = input()
lengths = input()
length_list = [int(s) for s in lengths.split(' ')]
res = [0]
for i in range(max(length_list)):
	if len(res) <= max(length_list) - 1:
		res.append(0)
	for j in range(len(length_list)):
		if length_list[j] < i:
			res[i] += i - 1 - length_list[j]
		elif length_list[j] > i:
			res[i] += length_list[j] - (i + 1)
index_min = res.index(min(res))
if index_min == 0:
	print(1, min(res))
else:
	print(index_min, min(res))


n = int(input())
cl = list(map(int, input().split()))
st = set(cl)
lst = len(st)
st = list(st)
ser = 1
mn = 10 ** 10
for i in range(1, max(cl) + 1):
	sm = 0
	for j in range(lst):
		if abs(st[j] - i) > 1:
			sm += cl.count(st[j]) * (abs(st[j] - i) - 1)
	if sm < mn:
		mn = sm
		ser = i
print(ser, mn)


n = int(input())
a = [int(v) for v in input().split()]
s = sum(a)
k = 0
ans = 0
minn = 100000000
for i in range(1, 101):
	ans = 0
	for j in range(n):
		if abs(a[j] - i) > 1:
			ans += abs(a[j] - i) - 1
	if ans < minn:
		minn = ans
		k = i
print('{0} {1}'.format(k, minn))


n = int(input())
arr = list(map(int, input().split()))
ans = {}

def solve(t):
	cost = 0
	for num in arr:
		if num > t:
			cost += num - (t + 1)
		elif num < t:
			cost += t - 1 - num
	if cost not in ans:
		ans[cost] = [str(t)]
	else:
		ans[cost].append(str(t))
	return cost
mincost = 90000000000
for t in range(1, 101):
	mincost = min(mincost, solve(t))
print(ans[mincost][0], mincost)


n = int(input())
l = [int(s) for s in input().split()]
res = []
for i in range(1, 1001):
	re = 0
	t = i
	for j in range(len(l)):
		if abs(l[j] - t) <= 1:
			continue
		else:
			re += abs(l[j] - t) - 1
	res.append(re)
rt = min(res)
print(res.index(rt) + 1, rt)


n = int(input())
l = list(map(int, input().split()))
cost = None
h = 1
for t in range(1, 101):
	temp = 0
	for i in l:
		temp += min(abs(t - i), abs(t + 1 - i), abs(t - 1 - i))
	if t != 1:
		if cost > temp:
			h = t
			cost = temp
	else:
		cost = temp
print(h, cost)


n = input()
a = list(map(int, input().split()))
t = 0
count = 1000000
for i in range(1, 101):
	cost = sum((0 if k == i else abs(i - k) - 1 for k in a))
	if cost < count:
		count = cost
		t = i
print(t, count)


n = int(input())
a = [int(x) for x in input().split()]
l = 1000000
for i in range(1, 100):
	c = 0
	for j in range(len(a)):
		c += max(0, abs(a[j] - i) - 1)
	if c < l:
		l = c
		t = i
print(t, l)


n = int(input())
a = [int(s) for s in input().split()]
min = 10 ** 10
mint = 1
for t in range(1, 101):
	price = 0
	for j in range(n):
		stick = abs(a[j] - t)
		if stick > 1:
			price = price + stick - 1
	if price < min:
		mint = t
		min = price
print(mint, min)


n = int(input())
a = list(map(int, input().split()))
t_min = 0
v_min = int(1000000000.0)
for t in range(1, 101):
	v = 0
	for i in a:
		if abs(t - i) > 1:
			v += abs(t - i) - 1
	if v < v_min:
		v_min = v
		t_min = t
print(t_min, v_min)


amount = int(input())
array = [int(s) for s in input().split()]
max_ = max(array)
min_ = 10000000000.0
idx = -1
for i in range(1, max_ + 1):
	sum_ = 0
	for elem in array:
		if elem < i - 1:
			sum_ += i - 1 - elem
		elif elem > i + 1:
			sum_ += elem - i - 1
	if sum_ < min_:
		min_ = sum_
		idx = i
print(idx, min_)


n = int(input())
a = input().split()
for i in range(n):
	a[i] = int(a[i])
a.sort()
b = []
for j in range(2, 100):
	ans = 0
	for k in range(n):
		if a[k] - j > 1:
			ans += a[k] - j - 1
		elif a[k] - j < -1:
			ans += j - a[k] - 1
	b.append([ans, j])
ans = 0
for j in range(n):
	if a[j] > 2:
		ans += a[j] - 2
b.append([ans, 1])
b.sort()
print(b[0][1], b[0][0])


n = int(input())
a = tuple(map(int, input().split()))
ans = [0] * 110
count = 0
for t in range(1, 111):
	count = 0
	for i in a:
		if abs(i - t) <= 1:
			continue
		else:
			v = i - t
			f = min(abs(v), min(abs(v + 1), abs(v - 1)))
			count += f
		ans[t - 1] = count
m = min(ans)
print(ans.index(m) + 1, m)


import sys
input = sys.stdin.readline
n = int(input())
a = list(map(int, input().split()))
ans = 99999999999
bestT = 0
for i in range(1, 201):
	total = 0
	for j in a:
		total += min(abs(j - (i + 1)), abs(j - (i - 1)), abs(j - i))
	if total < ans:
		ans = total
		bestT = i
print(str(bestT) + ' ' + str(ans))


n = int(input().strip())
a = list(map(int, input().strip().split()))
anssum = float('inf')
ans = float('inf')
for i in range(1, 102):
	cs = 0
	for j in a:
		if abs(j - i) > 1:
			if j > i + 1:
				cs += j - i - 1
			elif j < i - 1:
				cs += i - 1 - j
			else:
				assert False
	if cs < anssum:
		anssum = cs
		ans = i
print(ans, anssum)


n = int(input())
a = list(map(int, input().split()))
m = 1000 * 1000
x = -1
for i in range(1, 101):
	c = 0
	for j in range(len(a)):
		if a[j] == i or a[j] - 1 == i or a[j] + 1 == i:
			continue
		elif a[j] > i:
			c += abs(a[j] - i - 1)
		elif a[j] < i:
			c += abs(-a[j] + i - 1)
	if c < m:
		m = c
		t = i
else:
	print(t, m)


n = int(input())
l = list(map(int, input().split()))
t = 0
ans = 10 ** 9
for i in range(1, 101):
	val = 0
	for j in l:
		val += max(abs(j - i) - 1, 0)
	if val < ans:
		t = i
		ans = val
print(t, ans)


n = int(input())
newlist = []
flist = []
mylist = input().split()
for i in range(len(mylist)):
	newlist.append(int(mylist[i]))
for t in range(1, 101):
	m = 0
	for i in range(len(newlist)):
		if t != newlist[i]:
			m += abs(t - newlist[i]) - 1
	flist.append((m, t))
a = min(flist)
print(a[1], end=' ')
print(a[0])


num = int(input().strip())
nums = [int(i) for i in input().strip().split()]
t = 0
cost = 1000000
for i in range(1, 101):
	c = 0
	for j in nums:
		if j != i:
			c += abs(j - i) - 1
		else:
			pass
	if c < cost:
		cost = c
		t = i
print(t, cost)


import sys
input = sys.stdin.readline
n = int(input())
l = list(map(int, input().split()))
l.sort()
m1 = l[0]
m2 = l[-1]
t = (m1 + m2) // 2
s = 0
m = 1098765
ans = 0
for i in range(1, 100):
	for j in l:
		if j > i:
			s += j - i - 1
		elif j < i:
			s += i - 1 - j
	if s < m:
		m = s
		ans = i
	s = 0
print(ans, m)


t = 1000000
naj = 0
n = int(input())
a = [int(x) for x in input().split()]
for i in range(1, 101):
	temp = 0
	for x in a:
		temp += (abs(i - x) - 1, 0)[abs(i - x) == 0]
	if temp < t:
		t = temp
		naj = i
print(naj, t)


su = 0
(minx, miny) = (None, 0)
n = int(input())
a = [int(x) for x in input().split()]
for t in range(1, 100):
	su = 0
	for i in range(n):
		if abs(a[i] - t) > 1:
			su += min(abs(a[i] - t - 1), abs(a[i] - t), abs(a[i] - t + 1))
	if minx == None or minx > su:
		minx = su
		miny = t
print(miny, minx)


n = int(input())
a = list(map(int, input().split()))
mas = []
for i in range(1, 1001):
	x = 0
	for j in range(n):
		if abs(a[j] - i) > 1:
			x += abs(a[j] - i) - 1
	mas.append((x, i))
print(min(mas)[1], min(mas)[0])


n = int(input())
a = [int(s) for s in input().split()]
print(*min(((t, sum((max(abs(t - i) - 1, 0) for i in a))) for t in range(1, 101)), key=lambda t: t[1]))


import math, string, itertools, fractions, heapq, collections, re, array, bisect, sys, random, time, copy, functools
sys.setrecursionlimit(10 ** 7)
inf = 10 ** 20
eps = 1.0 / 10 ** 10
mod = 10 ** 9 + 7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]

def LI():
	return [int(x) for x in sys.stdin.readline().split()]

def LI_():
	return [int(x) - 1 for x in sys.stdin.readline().split()]

def LF():
	return [float(x) for x in sys.stdin.readline().split()]

def LS():
	return sys.stdin.readline().split()

def I():
	return int(sys.stdin.readline())

def F():
	return float(sys.stdin.readline())

def S():
	return input()

def pf(s):
	return print(s, flush=True)

def main():
	n = I()
	a = LI()
	mm = inf
	mi = 0
	for i in range(1, 100):
		t = 0
		for c in a:
			if c < i:
				t += i - 1 - c
			elif c > i:
				t += c - 1 - i
		if mm > t:
			mi = i
			mm = t
	return '{} {}'.format(mi, mm)
print(main())


import collections, atexit, math, sys, bisect
sys.setrecursionlimit(1000000)

def getIntList():
	return list(map(int, input().split()))
try:
	import numpy

	def dprint(*args, **kwargs):
		print(*args, file=sys.stderr)
	dprint('debug mode')
except Exception:

	def dprint(*args, **kwargs):
		pass
inId = 0
outId = 0
if inId > 0:
	dprint('use input', inId)
	sys.stdin = open('input' + str(inId) + '.txt', 'r')
if outId > 0:
	dprint('use output', outId)
	sys.stdout = open('stdout' + str(outId) + '.txt', 'w')
	atexit.register(lambda : sys.stdout.close())
(N,) = getIntList()
za = getIntList()
assert len(za) == N
r = 1000000000
for i in range(1, 101):
	t = 0
	for x in za:
		c1 = abs(x - i - 1)
		c2 = abs(x - i)
		c3 = abs(x - i + 1)
		t += min(c1, c2, c3)
	if t < r:
		r = t
		ri = i
print(ri, r)


n = int(input())
al = list(map(int, input().split()))
res = (1e309, 1)
for t in range(1, 101):
	c = 0
	for a in al:
		c += max(abs(a - t) - 1, 0)
	res = min(res, (c, t))
print('{a[1]} {a[0]}'.format(a=res))


n = int(input())
li = list(map(int, input().split()))
li2 = []
for i in range(102):
	cn = 0
	for j in range(n):
		cn += abs(i - li[j])
		if li[j] > i or li[j] < i:
			cn -= 1
	li2.append(cn)
	cn = 0
li2[0] = 1000000
ab = min(li2)
ba = li2.index(ab)
print(ba, ab)


n = int(input())
t = list(map(int, input().split()))
g = 0
ans = 999999999
for j in range(1, 101):
	x = 0
	for i in t:
		x += min(abs(i - j), abs(i - (j - 1)), abs(i - (j + 1)))
	if x < ans:
		ans = x
		g = j
print(g, ans)


N = int(input())
number_list = list(map(int, input().split(' ')))
ret = [0, 9999999]
for n in range(1, 101):
	temp = 0
	for number in number_list:
		temp += max(0, abs(number - n) - 1)
	if ret[1] > temp:
		ret[0] = n
		ret[1] = temp
print(ret[0], ret[1])


n = int(input())
l = list(map(int, input().split()))
(ans, mx) = (0, 100000000)
for i in range(1, 101):
	c = 0
	for j in l:
		if abs(i - j) > 1:
			c += abs(i - j) - 1
	if mx > c:
		mx = c
		ans = i
print(ans, mx)


n = int(input())
m = list(map(int, input().split()))
s = 0
mx = 10000000
for j in range(100):
	x = 0
	for i in range(n):
		if abs(m[i] - j - 1) > 0:
			x += abs(m[i] - j - 1) - 1
	if x < mx:
		mx = x
		s = j + 1
print(int(s), int(mx))


n = int(input())
a = list(map(int, input().split()))
m = 100000000
t = 100000000
for i in range(1, 101):
	u = 0
	for j in a:
		if i > j:
			u += i - j - 1
		elif i < j:
			u += j - i - 1
	if m > u:
		m = u
		t = i
print(t, m)


def main():
	n = int(input())
	a = list(map(int, input().split()))
	(ans1, ans2) = (10000000, 0)
	for i in range(1, 101):
		cur = 0
		for j in a:
			if j < i:
				cur += max(0, i - j - 1)
			else:
				cur += max(0, j - i - 1)
		if cur < ans1:
			(ans1, ans2) = (cur, i)
	print(ans2, ans1)
main()


def findCost(s, t):
	r = 0
	for stick in s:
		dif = abs(stick - t)
		if dif > 1:
			r += dif - 1
	return r
input()
sticks = list()
maximun = 0
minimun = float('inf')
min_t = None
for stick in input().split():
	nu = int(stick)
	maximun = max(maximun, nu)
	sticks.append(nu)
for t in range(1, maximun + 1):
	m = findCost(sticks, t)
	if m < minimun:
		minimun = m
		min_t = t
print(min_t, minimun)


def cin():
	n = int(input())
	return n
n = cin()
a = list(map(int, input().split()))
T = 0
ans = 100000
for t in range(1, 100):
	s = 0
	for i in a:
		if abs(t - i) > 1:
			s += abs(t - i) - 1
	if ans > s:
		ans = s
		T = t
print(T, ans)


n = int(input())
a = list(map(int, input().split()))
a.sort()
mn = 20000000000000
t = a[len(a) - 1]
amx = t
for i in range(1, amx + 1):
	k = 0
	for j in a:
		if 1 < abs(j - i):
			if j > i:
				k += j - i - 1
			elif j < i:
				k += i - 1 - j
	if mn > k:
		mn = k
		t = i
print(t, mn)


n = int(input())
a = list(map(int, input().split()))

def min_dist(ai, t):
	if ai < t:
		return t - 1 - ai
	if ai > t:
		return ai - (t + 1)
	else:
		return 0
t_min = -1
min_found = float('inf')
for t in range(1, 101):
	min_len = sum((min_dist(ai, t) for ai in a))
	if min_len < min_found:
		min_found = min_len
		t_min = t
print(f'{t_min} {min_found}')