object Main extends App {
  val sc = new java.util.Scanner(System.in)
  val n = sc.nextLong
  val nn = n - 1
//  def ModSum(n: Long): AnyVal = {
  //    val nn = (n - 1)
  //    (1 + nn) * nn / 2
  //  }

  println((1 + nn) * nn / 2)
}