'use strict';

function main(stdin) {
  const N = Number(stdin);
  let ans = 0;

  for (let i = 1; i < N; ++i) {
    ans += i;
  }
  
  console.log(ans);
}

main(require('fs').readFileSync('/dev/stdin', 'utf8').trim());