Permutation p is an ordered set of integers p_1,  p_2,  ...,  p_{n}, consisting of n distinct positive integers, each of them doesn't exceed n. We'll denote the i-th element of permutation p as p_{i}. We'll call number n the size or the length of permutation p_1,  p_2,  ...,  p_{n}.

You have a sequence of integers a_1, a_2, ..., a_{n}. In one move, you are allowed to decrease or increase any number by one. Count the minimum number of moves, needed to build a permutation from this sequence.


-----Input-----

The first line contains integer n (1 ≤ n ≤ 3·10^5) — the size of the sought permutation. The second line contains n integers a_1, a_2, ..., a_{n} ( - 10^9 ≤ a_{i} ≤ 10^9).


-----Output-----

Print a single number — the minimum number of moves.

Please, do not use the %lld specifier to read or write 64-bit integers in C++. It is preferred to use the cin, cout streams or the %I64d specifier.


-----Examples-----
Input
2
3 0

Output
2

Input
3
-1 -1 2

Output
6



-----Note-----

In the first sample you should decrease the first number by one and then increase the second number by one. The resulting permutation is (2, 1).

In the second sample you need 6 moves to build permutation (1, 3, 2).

Difficulty: interview

Starter code:

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

ans = 0
for i in range(n):
    ans += abs (arr[i] - i - 1)
print (ans)


n = int(input())
s = list(map(int, input().split()))
s.sort()
ans = sum([abs((i + 1) - s[i]) for i in range(n)])
print (ans)


N=int(input())


A=list(map(int,input().split()))
ans=0
A.sort()
for i in range(N):
    ans+=abs(A[i]-(i+1))
print(ans)
    


import sys
my_file = sys.stdin
#my_file = open("1input.txt", "r")
n = int(my_file.readline())
a = [int(i) for i in my_file.readline().strip().split()]
a.sort()
b = list(range(1, n+1))
# for i in range(n):
#     if a[i] <= n and a[i] >= 1:
#         b[i], b[a[i]-1] = b[a[i]-1], b[i]
turns = 0
for i in range(n):
    if a[i] < b[i]:
        turns += b[i] - a[i]
    elif a[i] > b[i]:
        turns += a[i] - b[i]
print(turns)

import sys
my_file = sys.stdin
#my_file = open("1input.txt", "r")
n = int(my_file.readline())
a = [int(i) for i in my_file.readline().strip().split()]
a.sort()
def solve():
    turns = 0
    for i in range(1, n+1):
        if a[i-1] < i:
            turns += i - a[i-1]
        elif a[i-1] > i:
            turns += a[i-1] - i
    return turns
print(solve())

n = int(input())
t = list(map(int, input().split()))
t.sort()
print(sum(abs(t[i] - i - 1) for i in range(n)))

n = int(input())
A = sorted(list(map(int, input().split())))
cnt = 0
for i in range(n):
    cnt += abs(A[i] - (i + 1))
print(cnt)

n = int(input())
a = list(map(int, input().split()))
a.sort()
s = 0
for i in range(n):
    s += abs(a[i] - i - 1)
print(s)



n = int(input())
a = sorted(list(map(int, input().split())))
ans = 0
for i in range(n):
    ans += abs(a[i] - i - 1)
print(ans)

n = int(input())
p = list(map(int,input().split()))
total = 0
j = 1
for i in sorted(p):
    total += abs(i-j)
    j+=1
print(total)

nums = int(input())
perm = list(map(int, input().split(' ')))
perm.sort()
total = 0
for i in range(len(perm)):
    total += abs(perm[i] - (i+1))
print(total)


n, val = int(input()), 0
for x, y in zip(sorted(int(x) for x in input().split()), range(1, n + 1)):
    val += abs(x - y)
print(val)

import sys
import math

n = int(sys.stdin.readline())
a = [int(x) for x in (sys.stdin.readline()).split()]

a.sort()
res = 0
for i in range(n):
    res += int(math.fabs(i + 1 - a[i]))
    
print(res)

n   = int(input())
seq = sorted(list(map(int, input().split())))

res = 0
for i in range(n):
    res += abs(seq[i] - (i+1))

print(res)


n = int(input())
l = sorted([int(x) for x in input().split()])
print(sum(abs(a - (b + 1)) for a, b in zip(l, list(range(n)))))


def main():
    n = int(input()) + 1
    l = [True] * n
    l[0] = False
    tail = []
    for a in map(int, input().split()):
        if 0 < a < n and l[a]:
            l[a] = False
        else:
            tail.append(a)
    tail.sort()
    print(sum(abs(a - b) for a, b in zip((i for i, _ in enumerate(l) if _), tail)))


def __starting_point():
    main()

__starting_point()

def main():
    n = int(input())
    print(sum(abs(a - b) for a, b in zip(sorted(map(int, input().split())), list(range(1, n + 1)))))


def __starting_point():
    main()

__starting_point()

# coding: utf-8
n = int(input())
a = [int(i) for i in input().split()]
a.sort()
ans = 0
for i in range(1,n+1):
    ans += abs(a[i-1]-i)
print(ans)


n=int(input())
p=input().split()
a=[]
for i in range(n):
    a.append(int(p[i]))
    i=i+1
a.sort()
c=0
for i in range(n):
    c=c+abs((i+1)-a[i])
print(c)


n = int(input())
a = sorted(map(int, input().split()))
print(sum([abs(a[i]-i-1) for i in range(n)]))

a=int(input())
b=sorted(map(int,input().split()))
print(sum([abs(b[i]-i-1)for i in range(a)]))


n=int(input())
mas=list(map(int,input().split(" ")))
mas.sort()
res=0
for i,x in enumerate(mas):
    res+=(abs(i-x+1))
print(res)

n = int(input())
a = [int(x) for x in input().split()]
a.sort()
res = 0
for i in range(len(a)):
    res += abs(i+1-a[i])
print(res)

n = int(input())
a = input().split()
for i in range(n):
    a[i] = int(a[i])
a.sort()
answ = 0
for i in range(n):
    answ += abs(a[i]-i-1)
print(answ)

x = int(input())
j = sorted([int(i) for i in list(input().split())])
javab =0
for i in range(x):
    javab+=abs(i+1 - j[i])
print(javab)