N=input() ans = 0 for i in range(0,N): ans += i print(ans)