N = int(input()) P = list(map(int, input().split())) print(max(0, N * (N + 1)//2 - 2))