import sys input = sys.stdin.readline sys.setrecursionlimit(10**7) N = int(input()) if N == 1: print(0) else: print(N*(N+1)//2-2)