def slove():

    import sys

    input = sys.stdin.readline

    n = int(input().rstrip('\n'))

    t = 0

    for i in range(1, n):

        t += i

    print(t)





if __name__ == '__main__':

    slove()

import sys





def solve():

    input = sys.stdin.readline

    mod = 10 ** 9 + 7

    n = int(input().rstrip('\n'))

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





if __name__ == '__main__':

    solve()

def slove():
    import sys

    input = sys.stdin.readline
    n = int(input().rstrip("\n"))
    t = 0
    for i in range(1, n):
        t += i
    print(t)


if __name__ == "__main__":
    slove()

import sys


def solve():
    input = sys.stdin.readline
    mod = 10**9 + 7
    n = int(input().rstrip("\n"))
    print(((n - 1) * (1 + n - 1) // 2))


if __name__ == "__main__":
    solve()

-def slove(): -    import sys +import sys + +def solve(): +    mod = 10**9 + 7 -    t = 0 -    for i in range(1, n): -        t += i -    print(t) +    print(((n - 1) * (1 + n - 1) // 2)) -    slove() +    solve()