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: interview

Starter code:

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

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


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

# coding: utf-8

def main():
    N = int(input())

    ans = N * (N - 1) // 2

    print(ans)

def __starting_point():
    main()

__starting_point()

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

sigma = lambda x : x*(x+1)//2

#--maincode----------------

n = int(input())
print(sigma(n-1))

def delete_head_zeros(n):
	n = str(n)
	l = len(n)
	if "." in n:
		l = n.find(".")
	head_zeros = 0
	for i in range(l - 1):
		if n[i] == "0":
			head_zeros += 1
		else:
			break

	return n[head_zeros:]

# compare a, b
# a, b: int or string
def bigint_compare(a, b):
	a = delete_head_zeros(a)
	b = delete_head_zeros(b)
	if len(a) > len(b):
		return 1
	elif len(a) < len(b):
		return -1
	else:
		if a > b:
			return 1
		elif a < b:
			return -1
		else:
			return 0

# calculate a + b
# a, b: int or string
def bigint_plus(a, b):
	a = str(a)
	b = str(b)

	d = max([len(a), len(b)])
	a = '0' * (d - len(a)) + a
	b = '0' * (d - len(b)) + b

	ans = ""
	carry = 0
	for i in range(d):
		s = int(a[-i-1]) + int(b[-i-1]) + carry
		carry = s // 10
		ans = str(s % 10) + ans
	else:
		if carry:
			ans = str(carry) + ans

	return ans

# calculate a - b
# a, b: int or string
def bigint_minus(a, b): 
	a = str(a)
	b = str(b)
	M = []
	m = []
	sign = ""

	if len(a) > len(b) or (len(a) == len(b) and a >= b):
		[M, m] = [a, b]
	else:
		[M, m] = [b, a]
		sign = "-"
	m = '0' * (len(M) - len(m)) + m

	ans = ""
	borrow = 0
	for i in range(len(M)):
		s = int(M[-i-1]) - int(m[-i-1]) - borrow
		if s < 0:
			borrow = 1
			s += 10
		else:
			borrow = 0
		ans = str(s) + ans

	return sign + delete_head_zeros(ans)

# calculate a * b
# a, b: int or string
def bigint_multiply(a, b):
	a = str(a)
	b = str(b)

	md = []
	for j in range(len(b)):
		carry = 0
		mj = ""
		for i in range(len(a)):
			m = int(a[-i-1]) * int(b[-j-1]) + carry
			carry = m // 10
			mj = str(m % 10) + mj
		else:
			if carry:
				mj = str(carry) + mj
		md.append(mj)

	ans = 0
	for k in range(len(md)):
		ans = bigint_plus(md[k] + "0" * k, ans)

	return ans


# calculate a / b to d digits after decimal point
# a, b, d: int or string
def bigint_divide(a, b, d = 0):
	a = str(a)
	b = str(b)
	d = int(d)
	if d < 0:
		d = 0

	ans = ""
	r = ""
	for i in range(len(a) + d):
		q = 0
		if i < len(a):
			r += a[i]
		elif i == len(a):
			ans += "."
			r += "0"
		else:
			r += "0"

		if bigint_compare(r, b) == -1:
			ans += str(q)
		else:
			while bigint_compare(r, b) >= 0:
				r = bigint_minus(r, b)
				q += 1
			ans += str(q)

	return delete_head_zeros(ans)

def main():
	N = input()
	print(
		bigint_divide(
			bigint_multiply(N, bigint_minus(N, 1))
			,2
		)
	)

main()

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

def __starting_point():
    slove()
__starting_point()

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

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


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

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

N=int(input())

print((((N-1)*N)//2))


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

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

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

N = int(input())

modsum = ((1+(N-1))*(N-1))//2

print(modsum)

N = int(input())
N -= 1

ans = (N + 1) * N // 2

print(int(ans))

# サンプル2を適当にsum(range)したらなんかわかった
# 愚直にrangeするとTLEなるので等差数列の和を使う
n = int(input())
x = (n * (n + 1)) // 2
print((x - n))


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

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


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

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())
ans = n * (n - 1) // 2
print(ans)

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

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

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


n=int(input())

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

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

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

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

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

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

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

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

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

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

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


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


N =int(input())

print(((N-1)*(N))//2)

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

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

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


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


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

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

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

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

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


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

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

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

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

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

N = int(input())

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

3
#coding: utf-8

N = int(input())

ret = (N * (N-1)) // 2
print(ret)

N = int(input())

ans = N*(N+1)//2 - N

print(ans)


n = int(input())
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())
print(n*(n-1)//2)

N = int(input())

print((N*(N-1)//2))


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

n = int(input())-1

print(n*(n+1)//2)

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

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

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

N=int(input())

print(((N-1)*N)//2)

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

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

import sys
import heapq


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


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

import sys
# import math
# import bisect
# import numpy as np
# from decimal import Decimal
# from numba import njit, i8, u1, b1 #JIT compiler
# from itertools import combinations, product
# from collections import Counter, deque, defaultdict

# sys.setrecursionlimit(10 ** 6)
MOD = 10 ** 9 + 7
INF = 10 ** 9
PI = 3.14159265358979323846

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()
    # P=2,3,...N-1,N,1
    # i=1,2,...N-2,N-1,N
    print(n*(n-1)//2)

def __starting_point():
    Main()
__starting_point()

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

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

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

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()


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

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

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

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

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

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

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


#ABC139 D

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

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

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

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

N=int(input())

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


if N == 1:
	print((0))
else:
	print(ans)


N = int(input())

print(((N*(N-1))//2))


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

N=int(input())

print(N*(N-1)//2)

N = int(input())

print((int(N*(N-1)//2)))


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

#from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
from math import gcd
from itertools import combinations,permutations,accumulate, product # (string,3) 3回
#from collections import deque
from collections import deque,defaultdict,Counter
import decimal
import re
import math
import bisect
import heapq
#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#
# my_round_int = lambda x:np.round((x*2 + 1)//2)
# 四捨五入g
#
# インデックス系
# int min_y = max(0, i - 2), max_y = min(h - 1, i + 2);
# int min_x = max(0, j - 2), max_x = min(w - 1, j + 2);
#
#
import sys
sys.setrecursionlimit(10000000)
# mod = 10**9 + 7
#mod = 9982443453
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())

print(N*(N-1)//2)

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


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

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

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

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

def __starting_point():
    main()

__starting_point()