Permutation *p* is an ordered set of integers *p*<sub class="lower-index">1</sub>,  *p*<sub class="lower-index">2</sub>,  ...,  *p*<sub class="lower-index">*n*</sub>, 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*<sub class="lower-index">*i*</sub>. We'll call number *n* the size or the length of permutation *p*<sub class="lower-index">1</sub>,  *p*<sub class="lower-index">2</sub>,  ...,  *p*<sub class="lower-index">*n*</sub>.

You have a sequence of integers *a*<sub class="lower-index">1</sub>, *a*<sub class="lower-index">2</sub>, ..., *a*<sub class="lower-index">*n*</sub>. 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.
The first line contains integer *n* (1 ≤ *n* ≤ 3·10<sup class="upper-index">5</sup>) — the size of the sought permutation. The second line contains *n* integers *a*<sub class="lower-index">1</sub>, *a*<sub class="lower-index">2</sub>, ..., *a*<sub class="lower-index">*n*</sub> ( - 10<sup class="upper-index">9</sup> ≤ *a*<sub class="lower-index">*i*</sub> ≤ 10<sup class="upper-index">9</sup>).
def mincheck(i,d,min1,max1,c):
    for j in range(min1,max1+1):
        if j not in d:
            c = abs(j-i)
            d[j] = 1
            return c,j+1

def maxcheck(i,d,min1,max1,c):
    for j in range(max1,min1-1,-1):
        if j not in d:
            c =abs(j-i)
            d[j] = 1
            return c,j+1
        
def check(i,d,min1,max1,c):
    x , y = i-1,i+1
    while x >= min1 or y <= max1:
        if x >=min1 and x not in d:
            d[x] = 1
            return abs(i-x)
        if y<=max1 and y not in d:
            d[y] = 1
            return abs(y-i)
        x -= 1
        y += 1

#from collections import Counter
#from collections import defaultdict
#import math
n = int(input())
#n,m = map(int,input().split())
l = list(map(int,input().split()))
#t = list(map(int,input().split()))

d = {}
min1 = 1 ; max1 = n
c = 0
for i in l:
    #print("i",i)
    if i <= 0:
        t,min1 = mincheck(i,d,min1,max1,c)
        c += t
        #print("first",t)
    elif i > n:
        t,max1 = maxcheck(i,d,min1,max1,c)
        c += t
        #print("second",t)
    elif i in d:
        t = check(i,d,min1,max1,c)
        c += t
        #print("third",t)
    else:
        d[i] = 1
#print(d)
print(c)

