def main(): import sys input = sys.stdin.readline N = int(input()) P = list(map(int,input().split())) count = 0 for i in range(N): if P[i] != N: count += i + 1 else: count -= i + 1 print(count) if __name__ == '__main__': main()