n = int(input()) ans = n * (n - 1) // 2 print(ans)