/*
                                        ^....0
                                    ^ .1 ^1^
                                    ..     01
                                    1.^     1.0
                                    ^ 1  ^    ^0.1
                                    1 ^        ^..^
                                    0.           ^ 0^
                                    .0            1 .^
                                    .1             ^0 .........001^
                                    .1               1. .111100....01^
                                    00             ^   11^        ^1. .1^
                                    1.^                              ^0  0^
                                    .^                                 ^0..1
                                    .1                                   1..^
                                    1 .0                                     ^  ^
                                    ^ 00.                                     ^^0.^
                                    1 ^ 0                                     ^^110.^
                                0.   0 ^                                    ^^^10.01
                        ^^     010^   1 1                                   ^^^1110.1
                        0001  10 0   ^ 1.1                                   ^^^1111110
                        0^ 10 . 01   ^^  ^^                                   ^^^1111^1.^           ^^^
                        10  10^ 0^                                             ^^111^^^0.1^       1....^
                            11     0                                               ^^11^^^ 0..  ....1^   ^ ^
                            1.     0^                                               ^11^^^ ^ 1 111^     ^ 0.
                        10   00 11                                               ^^^^^   1 0           1.
                        0^  ^0  ^0                                                ^^^^    0            0.
                        0^  1.0  .^                                               ^^^^    1 1          .0
                        ^.^  ^^  0^                             ^1                ^^^^     0.         ^.1
                        1 ^      11                             1.                ^^^     ^ ^        ..^
                        ^..^      ^1                             ^.^               ^^^       .0       ^.0
                        0..^      ^0                              01               ^^^       ..      0..^
                        1 ..        .1                             ^.^              ^^^       1 ^  ^0001
                        ^  1.        00                              0.             ^^^        ^.0 ^.1
                        . 0^.        ^.^                             ^.^            ^^^         ..0.0
                    1 .^^.         .^                  1001        ^^            ^^^         . 1^
                    . ^ ^.         11                0.    1         ^           ^^          0.
                        0  ^.          0              ^0       1                   ^^^          0.
                    0.^  1.          0^             0       .1                   ^^^          ..
                    .1   1.          00            .        .1                  ^^^           ..
                    1      1.         ^.           0         .^                  ^^            ..
                    0.     1.          .^          .         0                                  .
                    .1     1.          01          .        .                                 ^ 0
                    ^.^     00          ^0          1.       ^                                 1 1
                    .0      00           .            ^^^^^^                                   .
                    .^      00           01                                                    ..
                1.       00           10                                                   1 ^
                ^.1       00           ^.                                            ^^^    .1
                ..        00            .1                                        1..01    ..
                1.1         00           1.                                       ..^      10
                ^ 1^         00           ^.1                                      0 1      1
                .1           00            00                                       ^  1   ^
                .           00            ^.^                                        10^  ^^
            1.1           00             00                                              10^
            ..^           1.             ^.                                               1.
            0 1            ^.              00                 00                            .^
                ^            ^.              ^ 1                00   ^0000^     ^               01
            1 0             ^.               00.0^              ^00000   1.00.1              11
            . 1              0               1^^0.01                      ^^^                01
            .^              ^                1   1^^                                       ^.^
            1 1                                                                              0.
            ..                                                                              1 ^
            1                                                                               1
        ^ ^                                                                             .0
        1                                                                             ^ 1
        ..                                                          1.1            ^0.0
        ^ 0                                                           1..01^^100000..0^
        1 1                                                            ^ 1 ^^1111^ ^^
        0 ^                                                             ^ 1      1000^
        .1                                                               ^.^     .   00
        ..                                                                1.1    0.   0
        1.                                                                  .    1.   .^
        1.                                                                 1    1.   ^0
        ^ .                                                                 ^.1 00    01
        ^.0                                                                  001.     .^
        */
//#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <set>
#include <queue>
#include <map>
#include <deque>
const int maxn = 1e6 + 7;
typedef long long ll;
using namespace std;
const ll mod = 1e9+7;
const long double pi = 3.1415926535897932384626433832795;
int a[maxn];
int b[maxn];
int main(){
    ios::sync_with_stdio(false);
    //freopen("text.txt","r",stdin);
    //freopen("out2.txt","w",stdout);
    ll n;
    cin >> n;
    ll ans = (n-1) * (n) / 2;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256