#include <cstdio>
#include <iostream>

using namespace std;

int n;

int main (){
//  freopen("memory.in","r",stdin);
  //freopen("memory.out","w",stdout);
  cin >> n;
  cout << n*(n-1)/2 << endl;
  return 0;
}
