For an integer N, we will choose a permutation \{P_1, P_2, ..., P_N\} of \{1, 2, ..., N\}.
Then, for each i=1,2,...,N, let M_i be the remainder when i is divided by P_i.
Find the maximum possible value of M_1 + M_2 + \cdots + M_N.

-----Constraints-----
 - N is an integer satisfying 1 \leq N \leq 10^9.

-----Input-----
Input is given from Standard Input in the following format:
N

-----Output-----
Print the maximum possible value of M_1 + M_2 + \cdots + M_N.

-----Sample Input-----
2

-----Sample Output-----
1

When the permutation \{P_1, P_2\} = \{2, 1\} is chosen, M_1 + M_2 = 1 + 0 = 1.

Difficulty: MEDIUM_HARD

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


def main():
	N = int(input())
	ans = N * (N - 1) // 2
	print(ans)

def __starting_point():
	main()
__starting_point()


def slove():
	n = int(input())
	print(n * (n - 1) // 2)

def __starting_point():
	slove()
__starting_point()


a = int(input())
print(a * (a - 1) // 2)


from math import gcd
from itertools import combinations, permutations, accumulate, product
from collections import deque, defaultdict, Counter
import decimal
import re
import math
import bisect
import heapq
import sys
sys.setrecursionlimit(10000000)
mod = 998244353
INF = float('inf')
from sys import stdin
readline = stdin.readline

def readInts():
	return list(map(int, readline().split()))

def readTuples():
	return tuple(map(int, readline().split()))

def I():
	return int(readline())
n = I()
print((n - 1) * n // 2)


N = int(input())
nn = N - 1
print(nn * (nn + 1) // 2)


N = int(input())
mod = N * (N - 1) // 2
print(mod)


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


s = int(input())
print(s * (s - 1) // 2)


a = int(input())
print(a * a - a >> 1)


N = int(input())
M = N * (N - 1) // 2
print(M)


N = int(input())
print((0 + N - 1) * N // 2)


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


t = int(input())
print(t * (t - 1) // 2)


x = int(input())
print((x - 1) * x // 2)


i = int(input())
print((i - 1) * i // 2)


N = int(input())
S = N * (N - 1) // 2
print(S)


def resolve():
	n = int(input())
	print((n - 1) * n // 2)
resolve()


N = int(input())
ans = int(N * (N - 1) // 2)
if N == 1:
	print(0)
else:
	print(ans)


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


3
N = int(input())
ret = N * (N - 1) // 2
print(ret)


n = int(input())
if n == 1:
	print(0)
	return
if n == 2:
	print(1)
	return
if n % 2 == 1:
	print((n - 1 + 1) * ((n - 1) // 2))
else:
	print((n - 1 + 1) * ((n - 1) // 2) + n // 2)


N = int(input())
modsum = (1 + (N - 1)) * (N - 1) // 2
print(modsum)


N = int(input())
print((N ** 2 - N) // 2)


import sys
import heapq
input = sys.stdin.readline
n = int(input())
result = n * (n - 1) // 2
print(result)


N = int(input())
print(N * (N - 1) >> 1)


A = int(input())
print(int(A * (A - 1) // 2))


N = int(input().strip())
print(N * (N - 1) // 2)


N = int(input())
if N == 1:
	print(0)
	return
if N % 2 == 0:
	a = N // 2
	ans = (N - 1) * a
else:
	a = (N - 1) // 2
	ans = N * a
print(ans)


n = int(input())
k = (n * n - n) // 2
print(round(k))


N = int(input())
SUM = N * (N - 1) // 2
print(SUM)


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


N = int(input().rstrip())
print(N * (N - 1) // 2)


import sys
MOD = 10 ** 9 + 7
INF = 10 ** 9
PI = 3.141592653589793

def read_str():
	return sys.stdin.readline().strip()

def read_int():
	return int(sys.stdin.readline().strip())

def read_ints():
	return map(int, sys.stdin.readline().strip().split())

def read_ints2(x):
	return map(lambda num: int(num) - x, sys.stdin.readline().strip().split())

def read_str_list():
	return list(sys.stdin.readline().strip().split())

def read_int_list():
	return list(map(int, sys.stdin.readline().strip().split()))

def GCD(a: int, b: int) -> int:
	return b if a % b == 0 else GCD(b, a % b)

def LCM(a: int, b: int) -> int:
	return a * b // GCD(a, b)

def Main():
	n = read_int()
	print(n * (n - 1) // 2)

def __starting_point():
	Main()
__starting_point()


n = int(input())
print(n * (n - 1) >> 1)


import math
import collections
import itertools

def YesNo(Bool):
	if Bool:
		print('Yes')
	else:
		print('No')
	return

def resolve():
	N = int(input())
	ans = N * (N - 1)
	print(ans // 2)
resolve()


num = int(input())
print((num * num - num) // 2)


n = int(input())
a = 0
a += n * (n - 1) // 2
print(a)


N = int(input())
print(str(N * (N - 1) // 2))


k = int(input())
print(k * (k - 1) // 2)


sigma = lambda x: x * (x + 1) // 2
n = int(input())
print(sigma(n - 1))


X = int(input())
print(X * (X - 1) // 2)


N = int(input())
Answer = N * (N - 1) // 2
print(int(Answer))


print(*[n * (n - 1) // 2 for n in [int(input())]])


N = int(input())
n = N - 1
res = n * (n + 1) // 2
print(res)


N = int(input())
r = N * (N - 1) // 2
print(r)


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