n = int(input()) answer = int(0.5*(n**2-n)) print(answer)