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: interview

Starter code:

Solutions:
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())
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())
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)

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)


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 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())



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)

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())
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())
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 = 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())
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())
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())
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)

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())

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)

from sys import stdin
n=int(stdin.readline().strip())
#n,m=map(int,stdin.readline().strip().split())
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)
        
        


import math
n = int(input())
ar = [*map(int, input().split(' '))]
mint,mincost = int(1e9),int(1e9)
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())
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())
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)

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)