n=int(input()) a=list(map(lambda x : int(x) - 1,input().split())) ans=0 for i in range(n): for j in range(i+1,n): if a[j]==i: ans+=a[i]-i if a[j]