#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
void solve() {
  ll n;
  cin >> n;
  cout << (n - 1) * n / 2 << '\n';
}
int main() {
  solve();
  return 0;
}
