N, *P = map(int, open(0).read().split()) if N == 1: print(0) elif N == 2: print(0) else: print(N * (N + 1) // 2 - N + 1)