Problem:
 Score : 400 points    Problem Statement 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 1 2      Sample Output 1 1  When the permutation \{P_1, P_2\} = \{2, 1\} is chosen, M_1 + M_2 = 1 + 0 = 1 .       Sample Input 2 13      Sample Output 2 78       Sample Input 3 1      Sample Output 3 0

Solution (Python):
import sys
from collections import deque
import itertools
from collections import deque
sys.setrecursionlimit(10 ** 9)




def input():
    return sys.stdin.readline().rstrip()


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




if __name__ == "__main__":
    main()

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

Solution (Python):

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

Solution (Python):
n = int(input())

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

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

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

Solution (Python):


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

Solution (Python):
import sys
import math
import itertools as it
def I():return int(sys.stdin.readline().replace("\n",""))
def I2():return map(int,sys.stdin.readline().replace("\n","").split())
def S():return str(sys.stdin.readline().replace("\n",""))
def L():return list(sys.stdin.readline().replace("\n",""))
def Intl():return [int(k) for k in sys.stdin.readline().replace("\n","").split()]
def Lx(k):return list(map(lambda x:int(x)*-k,sys.stdin.readline().replace("\n","").split()))

if __name__ == "__main__":
    n = I()
    n -= 1
    print(n*(n+1)//2)

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

Solution (Python):
n=int(input());print((n*n-n)//2)

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

Solution (Python):
n = int(input())
s = (n * (n - 1)) // 2
print(s)

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

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

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

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

Solution (Python):
def main():
    n = int(input())

    print(sum(range(1,n)))

if __name__ == '__main__':
    main()

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

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

Solution (Python):
from collections import defaultdict
import bisect

def readInt():
	return int(input())
def readInts():
	return list(map(int, input().split()))
def readChar():
	return input()
def readChars():
	return input().split()


n = readInt()
print(n*(n-1)//2)

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

Solution (Python):
N=int(input())

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

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

Solution (Python):
n=int(input())

ans=0
for i in range(n):
  ans+=i
print(ans)

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

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

Solution (Python):
N = int(input())

ans = int((N-1) * (1+N-1)//2)
if N == 1:
    print(0)
    exit()
print(ans)

Solution (Python):
n=int(input())
ans=n*(n+1)//2
ans-=n
print(ans)

Solution (Python):
def main():
    import sys
    sys.setrecursionlimit(10**9)
    input = sys.stdin.readline

    N = int(input())

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

main()

Solution (Python):
def main():
    N = int(input())
    print(N * (N - 1) // 2)
    
if __name__ == "__main__":
    main()

Solution (Python):
n=int(input())

total = n*(n-1)//2
print(total)

Solution (Python):

import sys, re
from collections import deque, defaultdict, Counter, OrderedDict
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from heapq import heappush, heappop, heapify, nlargest, nsmallest
def STR(): return list(input())
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def list2d(a, b, c): return [[c] * b for i in range(a)]
def sortListWithIndex(listOfTuples, idx):   return (sorted(listOfTuples, key=lambda x: x[idx]))
def sortDictWithVal(passedDic):
    temp = sorted(passedDic.items(), key=lambda kv: (kv[1], kv[0]))
    toret = {}
    for tup in temp:
        toret[tup[0]] = tup[1]
    return toret
def sortDictWithKey(passedDic):
    return dict(OrderedDict(sorted(passedDic.items())))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

n = INT()

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

Solution (Python):
from decimal import *
N = int(input())
print(int(N*Decimal((N-1)/2)))

Solution (Python):
import math
N = int(input())
print(N*(N-1)//2)

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

Solution (Python):
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


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

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


if __name__ == '__main__':
    main()

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

Solution (Python):


n=int(input())

ans=0





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

print(ans)

Solution (Python):
import sys

sys.setrecursionlimit(10 ** 8)

input = sys.stdin.readline


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

    def sum_up_to_n(n):
        return n * (n + 1) // 2

    print(sum_up_to_n(N - 1))
    

if __name__ == '__main__':
    main()

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

Solution (Python):


import sys
input=sys.stdin.readline

def main():
    N=int(input())
    print(N*(N-1)//2)
    
if __name__=="__main__":
    main()

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

Solution (Python):
n=int(input())
print((n**2-n)//2)

Solution (Python):
import sys
sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline

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

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

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

Solution (Python):
mod=10**9+7
import math
import sys
from collections import deque
import heapq
import copy
import itertools
from itertools import permutations
from itertools import combinations
import bisect
def mi() : return map(int,sys.stdin.readline().split())
def ii() : return int(sys.stdin.readline().rstrip())
def i() : return sys.stdin.readline().rstrip()
a=ii()
print(a*(a-1)//2)

Solution (Python):
mod=10**9+7
import math
import sys
from collections import deque
import heapq
import copy
import itertools
from itertools import permutations
from itertools import combinations
import bisect
def mi() : return map(int,sys.stdin.readline().split())
def ii() : return int(sys.stdin.readline().rstrip())
def i() : return sys.stdin.readline().rstrip()
a=ii()
if a%2==0:
  b=a//2
  print(b*(a-1))
else:
  b=(a-1)//2
  print(a*b)

Solution (Python):



'''
import itertools

for N in range(1,13):
    l = [i for i in range(1,N+1)]

    ans = 0
    ans_permutation = list()

    for permutation in itertools.permutations(l, N):
        temp_ans = 0
        permutation = [0] + list(permutation)
        for i in range(1,N+1):
            temp_ans += i%permutation[i]

        if ans <= temp_ans:
            if ans < temp_ans:
                ans_permutation = list()
            ans = temp_ans    
            ans_permutation.append(list(permutation)[1:])

    print(N,ans,ans_permutation)
    














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

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

Solution (Python):

 

 
import sys
from fractions import gcd
import math
from math import ceil,floor
import collections
from collections import Counter
import itertools
 

 







 
N=int(input())




ans = 0

for i in range(N-1):
    ans += i+1

print(ans)

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

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

Solution (Python):
def main():
    n = int(input())
    ans = n*(n-1)//2
    print(ans)

if __name__ == '__main__':
    main()

Solution (Python):
n = int(input())
sum = n*(n+1)//2
print(sum-n)

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

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

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

Solution (Python):
n = int(input())
ans = 0
if n <= 2:
  ans = 1%n
else:
  ans = n*(n-1)//2
print(ans)

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

Solution (Python):
n = int(input())

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

Solution (Python):
from decimal import Decimal


n = int(input())

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

Solution (Python):


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

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

Solution (Python):
n=int(input())
res=n*(n-1)//2
print(res)

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

Solution (Python):
n=int(input())-1
ans=n*(1+n)
ans=ans//2
print(ans)

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

Solution (Python):
N=int(input());print(N*(N-1)//2)

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

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

Solution (Python):

import sys
from collections import deque, defaultdict
from itertools import combinations, combinations_with_replacement
import bisect
from math import factorial, sqrt, log, ceil, floor
sys.setrecursionlimit(1000000)


def main():
    
    

    

    N = int(input())

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


if __name__ == '__main__':
    main()

Solution (Python):
N = int(input())

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

Solution (Python):
n = int(input())

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

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

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

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

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

Solution (Python):
import sys, math
input = sys.stdin.readline
rs = lambda: input().strip()
ri = lambda: int(input())
rl = lambda: list(map(int, input().split()))
mod = 10**9 + 7

N = ri()

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

Solution (Python):
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60


def main():
    N = int(readline())
    print(N * (N - 1) // 2)
    return


if __name__ == '__main__':
    main()

Solution (Python):
N = int(input())

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

Solution (Python):
N = int(input())

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

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

Solution (Python):
n = int(input())
t=(n-1)*n//2
print(t)

Solution (Python):
import sys
from collections import defaultdict
from queue import deque
readline = sys.stdin.buffer.readline



def geta(fn=lambda s: s.decode()):
    return map(fn, readline().split())


def gete(fn=lambda s: s.decode()):
    return fn(readline().rstrip())


def main():
    n = gete(int)
    print(n * (n - 1) // 2)


if __name__ == "__main__":
    main()

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

Solution (Python):
N = int(input())

n = N
sum = (2 + (n - 1)) * n // 2

ans = sum - n

print(ans)

Solution (Python):
N = int(input())

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

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

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

Solution (Python):
n = int(input())

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

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

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

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

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

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

Solution (Python):
N=int(input());print(N*(N-1)//2)

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

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

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

Solution (Python):
print(sum(range(int(input()))))

Solution (Python):
N = int(input())

print(sum(range(1,N)))

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

Solution (Python):
n = int(input())

if n == 1:
    print(0)
elif n == 2:
    print(1)
else:
    print((1 + n - 1) * (n - 1) // 2)

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

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

Solution (Python):

N =int(input())



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

Solution (Python):
N = int(input())
print((N**2 - N) // 2)

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

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

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

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

Solution (Python):
N = int(input())

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

print(answer)

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

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

Solution (Python):
N = int(input())

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

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

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

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

Solution (Python):
N = int(input())
c = (N-1)*N//2
print(c)

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

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

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

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

Solution (Python):
n = int(input())

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

Solution (Python):
import sys
from collections import defaultdict
from queue import deque
readline = sys.stdin.buffer.readline



def geta(fn=lambda s: s.decode()):
    return map(fn, readline().split())


def gete(fn=lambda s: s.decode()):
    return fn(readline().rstrip())


def main():
    n = gete(int)
    print(n * (n - 1) // 2)


if __name__ == "__main__":
    main()

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

Solution (Python):
def main():
    n = int(input())
    print((n * (n - 1)) // 2)
        
if __name__ == '__main__':
    main()

Solution (Python):

"""
@author: H_Hoshigi
14min 05sec
"""


















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

if __name__ == "__main__":
    main()

Solution (Python):
import sys
import math
import itertools
import collections
import heapq
import re
import numpy as np

rr = lambda: sys.stdin.buffer.readline().rstrip()
rs = lambda: sys.stdin.buffer.readline().split()
ri = lambda: int(sys.stdin.buffer.readline())
rm = lambda: map(int, sys.stdin.buffer.readline().split())
rl = lambda: list(map(int, sys.stdin.buffer.readline().split()))

a = ri()
print((a * (a - 1)) // 2)

Solution (Python):
N = int(input())

S = sum(range(1,N))

print(S)

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

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

Solution (Python):
import math
N=int(input())

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

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

Solution (Python):
n = int(input())

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

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

Solution (Python):

import math


def inp():
    return(int(input()))



def inlist():
    return(list(map(int, input().split())))



def instr():
    s = input()
    return(list(s[:len(s)]))



def invr():
    return(map(int, input().split()))


n = inp()
n -= 1

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

Solution (Python):
import sys

input = lambda: sys.stdin.readline().rstrip()


def solve():
    N = int(input())
    if N == 1:
        print(0)
        exit()

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


if __name__ == '__main__':
    solve()

Solution (Python):
N = int(input())

ans = N * int(N - 1)

ans = ans // 2

print(ans)

Solution (Python):


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

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

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

Solution (Python):
if __name__ == "__main__":
    N = int(input())

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

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

Solution (Python):
N = int(input())

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

Solution (Python):
N = int(input())

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

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

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

Solution (Python):
n=int(input())
ans=n*(n-1)//2

print(ans)

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

Solution (Python):

import sys
input = sys.stdin.readline









N = int(input())


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

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

Solution (Python):
N = int(input())

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

Solution (Python):
from sys import stdin, setrecursionlimit


def main():
    input = stdin.buffer.readline
    n = int(input())
    print(n * (n - 1) // 2)


if __name__ == "__main__":
    setrecursionlimit(10000)
    main()

Solution (Python):
import sys
input = sys.stdin.readline
def main():
    N = int(input())
    ans = (N-1) * N // 2
    print(ans)
if __name__ == "__main__":
    main()

Solution (Python):

import sys
import math
from bisect import bisect_left, bisect_right, insort_left, insort_right
from collections import defaultdict, deque, Counter
from copy import deepcopy
from fractions import gcd
from functools import lru_cache, reduce
from heapq import heappop, heappush
from itertools import accumulate, groupby, product, permutations, combinations, combinations_with_replacement
from math import ceil, floor, factorial, log, sqrt, sin, cos
from operator import itemgetter
from string import ascii_lowercase, ascii_uppercase, digits
sys.setrecursionlimit(10**6)
INF = float('inf')
MOD = 10 ** 9 + 7
def rs(): return sys.stdin.readline().rstrip()
def ri(): return int(rs())
def rf(): return float(rs())
def rs_(): return [_ for _ in rs().split()]
def ri_(): return [int(_) for _ in rs().split()]
def rf_(): return [float(_) for _ in rs().split()]
def divisors(n, sortedresult=True):
    div = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            div.append(i)
            if i != n // i:
                div.append(n//i)
    if sortedresult:
        div.sort()
    return div

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

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

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

Solution (Python):
n = int(input())

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

Solution (Python):
n = int(raw_input())
print (n-1)*n/2

Solution (Python):

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

Solution (Python):
N = int(input())

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

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

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

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

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

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

Solution (Python):
N = int(input())


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

Solution (Python):
n=int(input())

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

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

Solution (Python):
n = int(input())

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

Solution (Python):
n = int(input())
s = (n*(n-1))//2
print(s)

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

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

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

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

Solution (Python):

def s0():return input()
def s1():return input().split()
def s2(n):return [input() for x in range(n)]
def s3(n):return [input().split() for _ in range(n)]
def s4(n):return [[x for x in s] for s in s2(n)]
def n0():return int(input())
def n1():return [int(x) for x in input().split()]
def n2(n):return [int(input()) for _ in range(n)]
def n3(n):return [[int(x) for x in input().split()] for _ in range(n)]
def t3(n):return [tuple(int(x) for x in input().split()) for _ in range(n)]
def p0(b,yes="Yes",no="No"): print(yes if b else no)








n=n0()

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

print(ans)

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

Solution (Python):
import sys
read = sys.stdin.buffer.read
input = sys.stdin.readline
input = sys.stdin.buffer.readline





def RD(): return sys.stdin.read()
def II(): return int(input())
def MI(): return map(int,input().split())
def MF(): return map(float,input().split())
def LI(): return list(map(int,input().split()))
def LF(): return list(map(float,input().split()))
def TI(): return tuple(map(int,input().split()))





def main():
	n=II()
	print(n*(n-1)//2)


if __name__ == "__main__":
	main()

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

Solution (Python):
def main():
    n = int(input())
    print(n*(n-1)//2)

if __name__ == '__main__':
    main()

Solution (Python):
n = int(input())

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

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

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

Solution (Python):
N = int(input())


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

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

Solution (Python):
n=int(input())

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

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

Solution (Python):
import sys
def input(): return sys.stdin.readline().strip()

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

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

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

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

Solution (Python):
import sys
from itertools import permutations

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60


def main():
    N = int(readline())
    print(N * (N - 1) // 2)
    return


if __name__ == '__main__':
    main()

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

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

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

Solution (Python):
N = int(input())

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

Solution (Python):
N = int(input())

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

Solution (Python):
N = int(input())

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

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

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

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

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

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

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

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

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

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

Solution (Python):
N = int(input())

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

Solution (Python):
N = int(input())

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

Solution (Python):
'''
参考
https://qiita.com/DaikiSuyama/items/ddb4544ee5df2f8d45c7
1～Nをある数で割った余りの合計を最大値にするためには、
2～Nで1～N-1を割ればよい（最後のNは1で割る）
以下の通り、余りは1～Nとなる
1 mod 2 = 1
2 mod 3 = 2
3 mod 4 = 3
…
（N-1) mod N = N-1
N mod 1 = N
https://mathwords.net/1karannowa
1～Nまでの和を求める公式
'''

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

Solution (Python):
N = int(input())

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

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

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

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

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

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

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

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

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

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

Solution (Python):
n=int(input())

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

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

Solution (Python):
import sys
import math
import itertools
n = int(input())
if(n%2==0):
    print((n + 1) * (n // 2) - n)
else:
    print((n + 1) * ((n-1) // 2) +(n+1)//2- n)

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

Solution (Python):
n = int(input())

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

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

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

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

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

Solution (Python):
N = int(input())

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

print(ans)

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

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

Solution (Python):
N = int(input())

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

Solution (Python):
N=int(input())

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

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

Solution (Python):
N = int(input())

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

Solution (Python):
import sys
import itertools
import numpy as np

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
 
n = int(input())

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

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

Solution (Python):


























n = int(input())

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

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

Solution (Python):
n = int(input())

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

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

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

Solution (Python):
import numpy as np
N = int(input())
print(N*(N-1)//2)

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

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

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

Solution (Python):




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

Solution (Python):
n=int(input())

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

Solution (Python):

N = int(input())


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

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

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

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

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

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

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

Solution (Python):
n = int(input())

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

Solution (Python):
n = int(input())

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

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

Solution (Python):
from math import ceil
N = int(input())
n = N -1
if n == 1:
    ans = 1
elif n%2 != 0:
    ans = (1+n)*(n//2) + ceil(n/2)
else:
    ans = (1+n)*(n//2)
print(ans)

Solution (Python):
N = int(input())


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

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

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

Solution (Python):
N = int(input())

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

print(ans)

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

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

Solution (Python):
n = int(input())

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

Solution (Python):
n = int(input())
print(sum(range(1, n)))

Solution (Python):






P = int(input())

















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

Solution (Python):
n = int(input())
a = n*(n-1)//2
print(a)

Solution (Python):
N = int(input())

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

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

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

Solution (Python):
N = int(input())
print(sum(range(N)))

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

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

Solution (Python):
N = int(input())

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

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

Solution (Python):


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

if __name__ == '__main__':
    main()

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

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

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

Solution (Python):
N = int(input())

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

Solution (Python):
n = int(input())

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

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

Solution (Python):
t=int(input());print(t*(t-1)//2)

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

Solution (Python):

import numpy as np
from collections import deque
import heapq
import collections
import itertools
import bisect
mod = 10 ** 9 + 7
N = int(input())

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

Solution (Python):
from math import ceil


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


if __name__ == '__main__':
    main()

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

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

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

if __name__ == "__main__":
  main()

Solution (Python):
N = int(input())

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

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

Solution (Python):
def main():
    n = int(input())
    print((n*(n+1))//2 - n)


if __name__ == '__main__':
    main()

Solution (Python):
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
def main():
    N = int(readline())
    print((N*(N-1))//2)
if __name__ == '__main__':
    main()

Solution (Python):

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

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

Solution (Python):
n = int(input())

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

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

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

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

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

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

Solution (Python):
import sys
def I(): return int(sys.stdin.readline().rstrip())
N = I()
print(N*(N-1)//2)

Solution (Python):


int1 = lambda x: int(x) - 1
def II(): return int(input())

def MI(): return map(int, input().split())
def MI1(): return map(int1, input().split())

def LI(): return list(map(int, input().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]

def tsum(l, r):
    return (r + l) * (r - l + 1) // 2

def solve():
    n = II()

    ans = tsum(1, n-1)
    print(ans)



if __name__ == '__main__':
    solve()

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

Solution (Python):
N = int(input())

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

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