n,*p=map(int,open(0).read().split()) a=0 for i in range(n): if p[i]==n: a-=i+1 else: a+=i+1 if n==1: a=0 print(a)