CodeEff/ECCO huggingface dataset:
# Original solution
N = int(eval(input()))
if N == 1:
    print((0))
    exit()

M = 1
for i in range(2, N):
    m = i % (i+1)
    M += m
print(M)

# Optimized solution
N = int(eval(input()))
N = N-1
if N % 2 == 0:
    print(((N+1) * (N//2)))
else:
    n = N-1
    print(((n+1) * (n//2) + N))
# Original solution
print((sum(range(int(eval(input()))))))


# Optimized solution
n = int(eval(input()))
print((n*(n-1)//2))
# Original solution
n = int(eval(input()))
ans = 0
for i in range(n-1):
    ans += (i+1)%(i+2)
print(ans)


# Optimized solution
n = int(eval(input()))
print((((n-1)*n)//2))
# Original solution
N=int(eval(input()))
n1=[x+1 for x in range(N)]
n2=n1[1:]+[n1[0]]
s=0
for x,y in zip(n1,n2):
    s+=x%y
print(s)

# Optimized solution
N=int(eval(input()))
ans=int((N-1)*N//2)
print(ans)
# Original solution
#!/usr/bin/env python
# coding: utf-8

# In[19]:


P = int(eval(input()))


# In[20]:


# i_list = list(range(1, P+1))
# p_list = i_list[1:]
# p_list.append(i_list[0])

# # print(i_list, p_list)

# ans = 0
# for i in range(P):
#     ans += i_list[i]%p_list[i]
# print(ans)

ans = sum(range(1,P))
print(ans)


# In[ ]:






# Optimized solution
#!/usr/bin/env python
# coding: utf-8

# In[21]:


P = int(eval(input()))


# In[22]:


# i_list = list(range(1, P+1))
# p_list = i_list[1:]
# p_list.append(i_list[0])

# # print(i_list, p_list)

# ans = 0
# for i in range(P):
#     ans += i_list[i]%p_list[i]
# print(ans)

# ans = sum(range(1,P))
ans = P*(P-1)//2
print(ans)


# In[ ]:
# Original solution
'''Haha this is python? How could you tell, Sherlock?'''

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

# Optimized solution
n=int(eval(input()))
suu=n*(n-1)//2
print(suu)
w=[1,2,3,4]
# Original solution
n = int(eval(input()))

num_list = [i+1 for i in range(n)]

print((sum(num_list) - n))

# Optimized solution
n = int(eval(input()))

print((sum(range(1, n + 1)) - n))
# Original solution
import sys
def input():
    return sys.stdin.readline().rstrip()

n = int(eval(input()))
h = [int(i) for i in range(n)]

print((sum(h[:n])))


# Optimized solution
import sys
def input():
    return sys.stdin.readline().rstrip()

n = int(eval(input()))
s = int((n*(n-1))//2)

print(s)
# Original solution
ans=0
for i in range(int(eval(input()))):
 ans+=i
print(ans)

# Optimized solution
n=int(eval(input()))
print(((n-1)*n//2))
# Original solution
F = [0, 0, 1]
    
while True:
    try:
        N = int(eval(input()))
        
        if N > len(F) - 1:
            for i in range(len(F), N+1):
                F.append(F[i-1] + i - 1)
        
        print((F[N]))
    except:
        break

# Optimized solution
R = [0, 0, 1]
while True:
    try:
        N = int(eval(input()))
        
        if N <= 2:
            print((R[N]))
        else:
            print(((N-1)*(N-2)//2 + N - 1))
    except:
        break
# Original solution
n = int(eval(input()))
n_list = [i for i in range(1,n)]
print((sum(n_list)))

# Optimized solution
n = int(eval(input()))
print((n*(n-1)//2))
# Original solution
N = int(eval(input()))
N_array = [x for x in range(1, N + 1, 1)]
N_array.pop(N - 1)
print((sum(N_array)))

# Optimized solution
N = int(eval(input()))
print((sum(range(1, N))))
# Original solution
N = int(eval(input()))
list = [i+1 for i in range(N)]
sum = 0

for i in range(1,N):
  sum += i

print(sum)

# Optimized solution
N = int(eval(input()))
print((N*(N-1)//2))
# Original solution
N = int(eval(input()))
P = [i for i in range(1, N + 1)]
# 1 2 3 4 5 6 7 8 9 10 11 12 13
# 2 3 4 5 6 7 8 9 10 11 12 13 1
print((sum(P) - P[-1]))


# Optimized solution
N = int(eval(input()))
ret = 0
for i in range(1, N):
    ret += i
# 1 2 3 4 5 6 7 8 9 10 11 12 13
# 2 3 4 5 6 7 8 9 10 11 12 13 1
print(ret)
# Original solution
N = int(eval(input()))
ans = 0
for i in range(N):
    ans += i

print(ans)

# Optimized solution
N = int(eval(input()))
print((N*(N-1)//2))
# Original solution
N = int(eval(input()))

if N == 1:
    print((0))
else:
    print((sum([i for i in range(1, N)])))


# Optimized solution
N = int(eval(input()))
print((N * (N-1) // 2))
# Original solution
n=int(eval(input()))
print((n*(n+1)//2-n))

# Optimized solution
n=int(eval(input()))
print((n*(n-1)//2))
# Original solution
n = int(eval(input()))

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

print(ans)


# Optimized solution
n = int(eval(input()))

print((n * (n - 1) // 2))
# Original solution
N=int(eval(input()))
res = 0
for i in range(1,N+1):
  if i == N:
    res += 0
  else:
    res += i%(i+1)
print(res)

# Optimized solution
N=int(eval(input()))
n=N-1
res = n*(n+1)//2
print(res)
# Original solution
n=int(eval(input()))
print((sum([i for i in range(1,n)])))

# Optimized solution
n=int(eval(input()))
print((n*(n-1)//2))
# Original solution
print((sum([_ for _ in range(int(eval(input())))])))

# Optimized solution
N=int(eval(input()))
print((int((N-1)*N//2)))
# Original solution
def main():
    N = int(eval(input()))
    ans = 0
    for i in range(1, N+1):
        if i != N:
            ans += i % (i+1)
    return ans
if __name__ == '__main__':
    print((main()))

# Optimized solution
def main():
    N = int(eval(input()))
    return N*(N-1)//2
if __name__ == '__main__':
    print((main()))
# Original solution
# 初期入力
N = int(eval(input()))

N_list =[i for i in range(1,N+1)]
ans =sum(N_list) -N
print(ans)

# Optimized solution
# 初期入力
N = int(eval(input()))

#N_list =[i for i in range(1,N+1)]
N_list_sum =N*(N+1)//2
ans =N_list_sum -N
print(ans)
# Original solution
n = int(eval(input()))
ans=0
for i in range(n):
    if i==n-1:
        break
    else:
        ans+=i+1
print(ans)

# Optimized solution
n = int(eval(input()))
ans = int((n-1)*n//2)
print(ans)
# Original solution
N = int(eval(input()))
lis = []
for i in range(1,N):
    lis.append(i)
print((sum(lis)))

# Optimized solution
N = int(eval(input()))
print((N*(N-1)//2))
# Original solution
n=int(eval(input()))
t=n-1
ans=t*(t+1)
print((ans//2))


# Optimized solution
n=int(eval(input()))-1
print((n*(n+1)//2))
# Original solution
import sys
import math
from copy import deepcopy
from collections import deque, defaultdict
from operator import mul
from functools import reduce
sys.setrecursionlimit(20000000)

# input = sys.stdin.readline


def main():
    n = int(eval(input()))

    ans = 0

    for i in range(1, n):
        ans += i

    print(ans)


if __name__ == '__main__':
    main()

# Optimized solution
import sys
import math
from copy import deepcopy
from collections import deque, defaultdict
from operator import mul
from functools import reduce
sys.setrecursionlimit(20000000)

# input = sys.stdin.readline


def main():
    n = int(eval(input())) - 1
    ans = 0

    if n % 2:
        print(((1 + n) * (n // 2) + (n // 2 + 1)))

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


if __name__ == '__main__':
    main()
# Original solution
n = int(eval(input()))

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



# Optimized solution
n = int(eval(input()))

print(((n * (n - 1))// 2))
# Original solution
N = int(eval(input()))

c = list()
for n in range(1, N+1):
    c.append(n)

d = c[:]
del d[0]
d.append(1)

cont = 0
for e, f in zip(c, d):
    mod = e % f
    cont += mod


print(cont)

# Optimized solution
N = int(eval(input()))
print(((N*(N-1))//2))
# Original solution
n = int(eval(input()))
ans = 0
for i in range(n):
  ans += i
print(ans)

# Optimized solution
n = int(eval(input()))

ans = 0
if n%2 != 0:
  ans = n*((n-1)//2)
else:
  ans = n*((n//2)-1) + n//2

print((int(ans)))
# Original solution
N = int(eval(input()))
ans = 0
for i in range(1, N):
    ans += i
print(ans)

# Optimized solution
N = int(eval(input()))
ans = 0
if N%2 == 0:
    ans = N//2 * (N-1)
else:
    ans = (N-1)//2 * N
print(ans)
# Original solution
a = int(eval(input()))
sum = 0
for i in range(a):
    sum += i
print(sum)


# Optimized solution
a = int(eval(input()))
sum = 0
sum = (a-1)* a // 2
print(sum)
# Original solution
N = int(eval(input()))

lis = [i for i in range(1, N)]

print((sum(lis)))


# Optimized solution
N = int(eval(input()))

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

print(ans)
# Original solution
N = int(eval(input()))
count = 0
for i in range(N):
    count += i
print(count)

# Optimized solution
N = int(eval(input()))
count = N * (N - 1) // 2
print(count)
# Original solution
import sys

N = int(eval(input()))

max = 0
for _ in range(1,N):
    max = max + _
print(max)


# Optimized solution
n = int(eval(input()))
print((n*(n-1)//2))
# Original solution
n = int(eval(input()))
ans = 0
for i in range(n-1,0,-1):
  ans += i%(i+1)
print(ans)  
     
  
  


# Optimized solution
n = int(eval(input()))
ans = (n-1)*n//2
print(ans)
# Original solution
n = int(eval(input()))

print((0 if n == 1 else sum([(i - 1)%i for i in range(2, n + 1)])))

# Optimized solution
n = int(eval(input()))
print(((n - 1)*n//2))
# Original solution
N = int(eval(input()))
m = 0

for n in range(1,N):
    if n == N:
        m += 0
    else:
        m += n % (n+1)
print(m)

# Optimized solution
n = int(eval(input()))
print((int((n-1)*n//2)))
# Original solution
n = int(eval(input()))
res = 0
for i in range(1,n):
    res += i%(i+1)
print(res)

# Optimized solution
n = int(eval(input()))
print((n*(n-1)//2))
# Original solution
n=int(eval(input()))
p=[]
total=0
for i in range(n,0,-1):
    p.append(i)
p.reverse()
for i in range(1,n):
    total+=i%p[i]
print(total)



# Optimized solution
n=int(eval(input()))
print((n*(n-1)//2))
# Original solution
n=int(eval(input()))
if n == 1:
  print('0')
else:
  total = 0
  for i in range(n):
    total += i
  print(total)

# Optimized solution
n=int(eval(input()))

total = n*(n-1)//2
print(total)
# Original solution
n =int(eval(input()))
ans = sum([i for i in range(n)])
print(ans)

# Optimized solution
n =int(eval(input()))
ans = n * (n - 1) // 2
print(ans)
# Original solution
li = [i for i in range(1, int(eval(input()))+ 1)]
print((sum(li[:-1])))

# Optimized solution
n = int(eval(input()))
print(((n * (n - 1)) // 2))
# Original solution
n = int(eval(input()))
print((sum((list(range(1,n))))))

# Optimized solution
n = int(eval(input()))
print((n*(n-1)//2))
# Original solution
n = int(eval(input()))
ans=0
for i in range(1, n):
    ans += i
print(ans)
        


# Optimized solution
n = int(eval(input()))
ans=0
ans = (n-1)*(n)//2
print(ans)
# Original solution
n = int(eval(input()))
print((int(n*(n-1)//2)))


# Optimized solution
n = int(eval(input()))
print((n*(n-1)//2))
# Original solution
N = int(eval(input()))

ans = 0
for num in range(N):
    ans += num


print(ans)

# Optimized solution
N = int(eval(input()))
a = N - 1
print((int(a*(a+1)//2)))
# Original solution

import math
N = int(eval(input()))

sum =0
for i in range(N):
	sum += i

print(sum)

# Optimized solution

import math
N = int(eval(input()))
print((int(N * (N - 1) // 2)))
# Original solution
n=int(eval(input()))
a=0
if n==1:
  print((0))
elif n==2:
  print((1))
else:
  for i in range(1,n):
    a+=(n-i)
  print(a)


# Optimized solution
n=int(eval(input()))
a=(n-1)*n//2
print((int(a)))
# Original solution
N = int(eval(input()))
print((sum(range(1, N))))

# Optimized solution
N = int(eval(input()))
print((N * (N - 1) // 2))
# Original solution
n = int(eval(input()))
print((sum(i for i in range(n))))

# Optimized solution
n = int(eval(input()))
print((n*(n-1)//2))
# Original solution
n = int(eval(input()))
ans = n%1
for i in range(2,n+1):
    ans += (i-1)%i
    # print(i-1,i,ans)
print(ans)

# Optimized solution
n = int(eval(input()))
print((n*(n-1)//2))
# Original solution
n = int(eval(input()))

print((sum([i for i in range(n)])))

# Optimized solution
n = int(eval(input()))

print((n * (n - 1) // 2))
# Original solution
import sys

ns = lambda: sys.stdin.readline().rstrip()
ni = lambda: int(ns())
na = lambda: [int(x) for x in ns().split()]
nall = lambda: [int(x) for x in sys.stdin.readlines()]


def main():
    n = ni()

    print((sum(range(n))))


if __name__ == '__main__':
    main()


# Optimized solution
import sys

ns = lambda: sys.stdin.readline().rstrip()
ni = lambda: int(ns())
na = lambda: [int(x) for x in ns().split()]
nall = lambda: [int(x) for x in sys.stdin.readlines()]


def main():
    n = ni()

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


if __name__ == '__main__':
    main()
# Original solution
N = int(eval(input()))
L = [i for i in range(1,N+1)]
print((sum(L[:-1])))

# Optimized solution
N = int(eval(input()))
print(((N-1)*(1+N-1)//2))
# Original solution
n = int(eval(input()))

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

print(ans)

# Optimized solution
n = int(eval(input()))
print((n*(n-1)//2))
# Original solution
N = int(eval(input()))
total = 0

for i in range(N):
    total += i
print(total)

# Optimized solution
N = int(eval(input()))
print((N*(N-1)//2))
# Original solution
N = int(eval(input()))
print((sum([i for i in range(N)])))

# Optimized solution
N = int(eval(input()))
tmp = 0
for i in range(N):
    tmp += i
print(tmp)
# Original solution
N=int(eval(input()))
if N==1:
  print((0))
  exit(0)
a=[i for i in range(1,N)]
print((sum(a)))

# Optimized solution
N=int(eval(input()))
if N==1:
  print((0))
  exit(0)
#a=[i for i in range(1,N)]
#print(sum(a))
if (N-1)%2==0:
  print((N*((N-1)//2)))
else:
  print((N*((N-1)//2)+((N-1)//2)+1))
# Original solution
# coding: utf-8
n = int(eval(input()))
ans = 0
for i in range(1,n):
    ans += i
print(ans)

# Optimized solution
# coding: utf-8
n = int(eval(input()))
ans = (n*(n-1))//2
print(ans)
# Original solution
n = int(eval(input()))
sum = 0
for i in range(n):
    sum += i

print(sum)


# Optimized solution
n = int(eval(input()))
if n % 2 == 0:
    sum = int(n/2)
    sum = sum *(n-1)

else:
    sum = int((n-1)/2)
    sum = sum * n

print((int(sum)))
# Original solution
N = int(eval(input()))
output = 0
for i in range(1,N):
    output += i
print(output)

# Optimized solution
N = int(eval(input()))
output = int(N*(N-1)//2)
print(output)
# Original solution
n = int(eval(input()))
total = 0
for i in range(n-1):
    total += i+1
print(total)

# Optimized solution
n = int(eval(input()))
total = 0
print((n*(n-1)//2))
# Original solution
n = int(eval(input()))
if n==1:
    print((0))
else:
    print((sum([i for i in range(n)])))

# Optimized solution
n = int(eval(input()))
print(((n-1)*n//2))
# Original solution
import sys
sys.setrecursionlimit(int(1e6))

N = int(eval(input()))

M_sum = 0
M_sum = sum(range(1, N))
M_sum += N % 1
print(M_sum)


# Optimized solution
import sys
sys.setrecursionlimit(int(1e6))

N = int(eval(input()))

n = N - 1
if bool(n%2):
    ans = (n//2) * (n) + n
else:
    ans = (n//2) * (n+1)

print(ans)
# Original solution
N = int(eval(input()))
ans = 0
P = []
P.append(N)
for i in range(N-1):
    P.append(i+1)

for i in range(N):
    ans = ans + (P[i] % (i+1))

print(ans)

# Optimized solution
N = int(eval(input()))
ans = 0
for i in range(N):
    ans += i
print(ans)
# Original solution
N = int(eval(input()))
M = [x+1 for x in range(N)]
print((sum(set(M))-N))

# Optimized solution
N = int(eval(input()))
ans = N*(N-1)//2
print(ans)
# Original solution
n = int(eval(input()))
ans = 0
for i in range(1, n):
	ans += i

print(ans)


# Optimized solution
n = int(eval(input()))
print(((n-1)*n//2))
# Original solution
n = int(eval(input()))

ans = 0

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

# Optimized solution
n = int(eval(input()))

print((n*(n-1)//2))
# Original solution
n = int(eval(input()))
print((sum([i for i in range(n)])))

# Optimized solution
n = int(eval(input()))
print((n*(n-1)//2))
# Original solution
n=int(eval(input()))
print((n*(n-1)//2))

# Optimized solution
n=int(eval(input()))

print(((n*(n-1))//2))
# Original solution
n = int(eval(input()))
ans = 0

for i in range(1, n):
    ans += i

print(ans)


# Optimized solution
n = int(eval(input())) - 1
print((n*(n+1)//2))
# Original solution
n = int(eval(input()))
sum = 0
for i in range(n):
  sum += i
print(sum)

# Optimized solution
n = int(eval(input()))
sum = n * (n - 1) // 2
print(sum)
# Original solution
n = int(eval(input()))
ans = sum(range(n))
print(ans)

# Optimized solution
n = int(eval(input()))
ans = n * (n-1)//2
print(ans)
# Original solution
def main():
    n = int(eval(input()))
    ans = 0

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

    print(ans)

if __name__ == '__main__':
    main()

# Optimized solution
def main():
    n = int(eval(input()))

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

    # print(ans)

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

if __name__ == '__main__':
    main()
# Original solution
N = int(eval(input()))

M = 0

for i in range(1, N):
    M = M + i

print(M)

# Optimized solution
N = int(eval(input()))

s = (N-1) * N // 2
print(s)
# Original solution
n = int(eval(input()))
ans = 0
for i in range(1,n):
    ans += i
print(ans)

# Optimized solution
n = int(eval(input()))
ans = 0
if ((n-1)%2==0):
    ans = (n)*((n-1)//2)
else:
    ans = (n)*((n-1)//2) + n//2
print(ans)
# Original solution
n = int(eval(input()))

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

print(ans)



 

 


                                        




    




        


    







        



# Optimized solution
n = int(eval(input()))

print((int(n*(n-1)//2)))
# Original solution
print((sum([i for i in range(1, int(eval(input())))])))

# Optimized solution
N = int(eval(input()))

if N % 2 == 0:
    print(((N-1)*N//2))
else:
    print((N*(N-1)//2))
# Original solution
N=int(eval(input()))

ans=0
for i in range(1,N):
    ans+=i
print(ans)
    


# Optimized solution
N=int(eval(input()))

ans=N*(N-1)//2
    
print(ans)
# Original solution
n = int(eval(input()))
ans = 0
for i in range(n):
    ans += i
print(ans)

# Optimized solution
n = int(eval(input()))
ans = 0
print((n*(n-1)//2))
# Original solution
N = int(eval(input()))
if N !=1:
    result = sum(range(1,N))
else:
    result = 0
print(result)

# Optimized solution
N = int(eval(input()))
result = N * (N-1)//2
print(result)
# Original solution
N = int(eval(input()))
print((sum(range(1, N))))


# Optimized solution
N = int(eval(input()))
print(((N-1) * N //2))
# Original solution
N=int(eval(input()))

total=[ a for a in range(N) ]

print((sum(total)))

# Optimized solution
N=int(eval(input()))
print(('{}'.format((N*(N-1)//2))))
# Original solution
n = int(eval(input()))

if n == 1:
    print((0))
elif n == 2:
    print((1))
else:
    print((sum(range(1, n))))

# Optimized solution
n = int(eval(input()))

if n == 1:
    print((0))
elif n == 2:
    print((1))
else:
    print(((1 + n - 1) * (n - 1) // 2))
# Original solution
n = int(eval(input()))
a = list(i for i in range(1, n+1))
p = a.copy()
p.append(p[0])
p.pop(0)
c = 0
for i in range(n):
    c += a[i] % p[i]
print(c)


# Optimized solution
n = int(eval(input()))
c = 0
for i in range(1, n+1):
    x = i + 1 if i < n else 1
    c += i % x
print(c)
# Original solution
N = int(eval(input()))
ans = 0
for i in range(1, N):
    ans += i
print(ans)

# Optimized solution
N = int(eval(input()))
print((N * (N - 1) // 2))
# Original solution
n = int(eval(input()))
sum = 0

for i in range(1,n):
  sum += i
  
print(sum)

# Optimized solution
n = int(eval(input()))
 
print((int(n*(n-1)//2)))
# Original solution
N= int(eval(input()))
ans=0
for i in range(N-1):
    ans+=i+1
print(ans)

# Optimized solution
N= int(eval(input()))
ans=N*(N-1)//2
print(ans)
# Original solution
n = int(eval(input()))
ans = 0
for i in range(1,n):
    ans +=i
print(ans)

# Optimized solution
n = int(eval(input()))
if n%2:
    p = ((n-1)//2)*n
    print((int(p)))
else:
    p = (n//2)*(n-1)
    print((int(p)))
# Original solution
n = int(eval(input()))
count = 0
if n==0:
    print(count)
    exit()
else:
    for i in range(n-1):
        count += i+1
print(count)

# Optimized solution
n = int(eval(input()))
count = (n-1)*n//2
print(count)
# Original solution
n = int(eval(input()))
ans = 0
for i in range(n):
  ans += i
print(ans)

# Optimized solution
n = int(eval(input()))
print((n*(n-1)//2))
# Original solution
import sys
sys.setrecursionlimit(10**6)
readline = sys.stdin.readline
n = int(eval(input()))

ans = sum([i for i in range(1,n)])

print(ans)

# Optimized solution
import sys
sys.setrecursionlimit(10**6)
readline = sys.stdin.readline
n = int(eval(input()))

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

print(ans)
# Original solution
N = int(eval(input()))
ans = 0

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

print(ans)

# Optimized solution
N = int(eval(input()))
print(((N * (N - 1)) // 2))
# Original solution
def main():
    n = int(eval(input()))
    not_n = (int(i) for i in range(1,n))
    print((sum(not_n)))
if __name__ == '__main__':
    main()

# Optimized solution
def main():
    n = int(eval(input()))
    not_n = ((n-1) * n)// 2
    print(not_n)
if __name__ == '__main__':
    main()
# Original solution
#abc139d
N = int(eval(input()))

if N>2:
    ans=0

    add = [i for i in range(2,N,1)]
    print((ans+sum(add)+1))
elif N==2:
    print("1")
elif N==1:
    print("0")

# Optimized solution
#139D

#ここから試験用コード
'''
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)
    
#試験用コードの結果
# 1  0 [[1]]
# 2  1 [[2, 1]]
# 3  3 [[1, 3, 2], [2, 3, 1]]
# 4  6 [[2, 3, 4, 1]]
# 5 10 [[1, 3, 4, 5, 2], [2, 1, 4, 5, 3], [2, 3, 4, 5, 1]]
# 6 15 [[2, 3, 4, 5, 6, 1]]
# 7 21 [[1, 3, 2, 5, 6, 7, 4], [1, 3, 4, 5, 6, 7, 2], [2, 3, 1, 5, 6, 7, 4], [2, 3, 4, 5, 6, 7, 1]]
# 8 28 [[2, 1, 4, 5, 6, 7, 8, 3], [2, 3, 4, 5, 6, 7, 8, 1]]
# 9 36 [[1, 3, 4, 5, 6, 7, 8, 9, 2], [2, 3, 4, 1, 6, 7, 8, 9, 5], [2, 3, 4, 5, 6, 7, 8, 9, 1]]
#10 45 [[2, 3, 4, 5, 6, 7, 8, 9, 10, 1]]

#いずれにも最初は2,3...、最後は1となるパターンがある
#上記パターン時は ((N-1)+1)*(N-1)/2 が答え。
'''
N = int(eval(input()))
print((N*(N-1)//2))
# Original solution
print((sum(range(1, int(eval(input()))))))

# Optimized solution
n = int(eval(input()))
print(((n - 1) * n // 2))
# Original solution
n = int(eval(input()))

if n == 1:
    print((0))
else:
    print((sum(range(1, n))))

# Optimized solution
n = int(eval(input()))

print((n * (n - 1) // 2))
# Original solution
print((sum(range(int(eval(input()))))))

# Optimized solution
n = int(eval(input()))
print((n * (n - 1) // 2))
# Original solution
n = int(eval(input()))
p2 = [ i + 1 for i in range(n-1)]
p2.append(0)
print((sum(p2)))

# Optimized solution
n = int(eval(input()))
print((n*(n-1)//2))
# Original solution
a = int(eval(input()))
result = 0
for i in range(a - 1):
  result = result + i + 1


print(result)

# Optimized solution
a = int(eval(input()))
print((int(a * (a - 1) // 2)))
# Original solution
N = int(eval(input()))
n = [x for x in range(1, N+1)]
print((sum(n[:-1])))

# Optimized solution
N = int(eval(input()))
print(((N+1) * N // 2 - N))
# Original solution
N = int(eval(input()))

M = 0

for i in range(1, N+1):
    M += i

M = M - N

print(M)

# Optimized solution
N = int(eval(input()))

M = 0

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


print((int(M)))
# Original solution
n = int(eval(input()))

A = [i for i in range(1, n+1)]
B = [i for i in range(2, n+1)]
B.append(1)

ans = 0
for a, b in zip(A, B):
    ans += a % b

print(ans)


# Optimized solution
n = int(eval(input()))

ans = 0
for i in range(1, n):
    ans += i % (i+1)

print(ans)
# Original solution
n = int(eval(input()))

ans = 0
for i in range(1, n):
    ans += i % (i+1)

print(ans)

# Optimized solution
n = int(eval(input()))

if n % 2 == 0:
    print(((n-1)*int(n/2)))
else:
    print((n*int((n-1)/2)))
# Original solution
n = int(eval(input()))
ans = 0
for i in range(n):
    ans += i
print(ans)

# Optimized solution
n = int(eval(input()))
ans = n * (n-1) // 2
print(ans)
# Original solution
n=int(eval(input()))
s=0
for i in range(n):
    s+=i
print(s)


# Optimized solution
n=int(eval(input()))
s=n*(n-1)//2
print(s)
# Original solution
N = int(eval(input()))
res = 0
for i in range(N):
    res += i

print(res)

# Optimized solution
N = int(eval(input()))
N -= 1
print((N*(N+1)//2))
# Original solution
a = int(eval(input()))
sum=0
for i in range(1,a):
    sum+=i
print(sum)


# Optimized solution
a = int(eval(input()))
print((a*(a-1)//2))