#include using namespace std; using ll=long long; ll mod=1000000007; ll INF=1LL<<60; int main() { ll N; cin >> N; cout << N*(N-1)/2<< endl; }