n = int(input()) a = sorted(list(map(int, input().split()))) b, c = [], [] d = set(a) ans = 0 nums = [i for i in range(1, 51) if not i in d] for i in a: if i in b: c.append(i) else: b.append(i) for i in range(len(c)): ans += abs(nums[i] - c[i]) print(ans)