n = int(input()) a = list(map(int, input().split())) sum1 = 0 sum2 = 0 for i in range(n): sum1 += i+1 sum2 += a[i] if sum2 > sum1: print(sum2 - sum1) else: print(sum1 - sum2)