N=int(input()) print(sum(range(1,N)))