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>).
# 5E

def main():
    n = int(input())

    p_list = input().split(" ")
    p_int_list = []

    hashtable = [False for _ in range(0, n+1)] # 0 is just unused
    running_total = 0

    for s in p_list:
        num = int(s)
        if (num < n and num > 0):
            hashtable[num] = True
        p_int_list.append(num);

    bottom_limit = 1
    top_limit = n
    for num in p_int_list:
        #print("1 num {}, top_lim {}, bottom_lim {}, running_total {}".format(num, top_limit, bottom_limit, running_total))
        
        if num <= 0:
            while bottom_limit < (n+1) and hashtable[bottom_limit] == True:
                bottom_limit += 1

            if bottom_limit >= (n+1):
                print("error!!!!!");
                break;

            running_total += bottom_limit - num;
            hashtable[bottom_limit] = True
        elif num >= n:
            while top_limit > 0 and hashtable[top_limit] == True:
                top_limit -= 1

            if top_limit <= 0:
                print("error!!!!!");
                break;

            running_total += num - top_limit;
            hashtable[top_limit] = True

        #print("2 num {}, top_lim {}, bottom_lim {}, running_total {}".format(num, top_limit, bottom_limit, running_total))

    print(running_total)

main()
   		  		 	  		 			  	 		  	 		