function Main(input) {
  input = input.split("\n");
  tmp = input[0].split(" ");
  var max_mod = Number(tmp[0]);
  var answer = max_mod*(max_mod-1)/2;
  console.log(answer);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));