n = int(input()) a = list(map(int, input().split())) cnt = {} for i in a: if i in cnt: cnt[i] += 1 else: cnt[i] = 1 ans = 0 tarinai = [] amari = [] for i in range(1,n+1): if i in cnt and cnt[i]>0: cnt[i] -= 1 else: tarinai.append(i) for i in cnt: if cnt[i] > 0: for j in range(cnt[i]): amari.append(i) amari.sort() for i,j in zip(tarinai, amari): ans += abs(i-j) print(ans)