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 mina(i):
    c1=i
#     print('jkhgvc',c1)
    while(hash1[c1]!=0):
        if (c1+1)<=n:
            c1+=1
        else:
            c1=-1
            break
#     print('c1',c1)
    return c1
def mina2(i):
    c2=i
    while(hash1[c2]!=0):
        if (c2-1)>0:
            c2-=1
        else:
            c2=-1
            break
    return c2
n = int(input())
l = list(map(int,input().split()))
hash1 = [0]*(n+1)
hash1[0] = 1
count=0
for i in l:
    if i>0 and i<=n and hash1[i]==0:
        hash1[i]=1
    elif i>0 and i<=n:
        c1 = mina(i)
        c2 = mina2(i)
#         print(c1,c2)
        if (c1-i)<(i-c2):
            count+=(c1-i)
            hash1[c1]=1
        else:
            count+=(i-c2)
            hash1[c2]=1
#         print('1',count)
    elif i<1 and i<=n:
        while(i<1):
            count+=1
            i+=1
#         print('i',i,c1)
        a = mina(i)
        hash1[a]=1
        count+=(a-i)
#         print(hash1)
#         print('2',count+((c1-i)))
    elif i>0 and i>n:
        while(i>n):
            count+=1
            i-=1
        a = mina2(i)
        hash1[a]=1
        count+=(i-a)
#         print('3',count)
print(count)
        
        
        
        
        