



object Main {

  def read(): Int = {
    scala.io.StdIn.readInt()
  }


  def solve(n: Long): Long = {
    n * (n-1) / 2
  }


  def main(args: Array[String]): Unit = {
    val n = read()
    println(solve(n))
  }

}
