Public Class Program
  Shared Sub Main()
    Dim n As Long = Long.Parse(Console.ReadLine())
    Dim ans As Long = 0
    For i As Long = 1 To n - 1
      ans += i
    Next
    Console.WriteLine(ans.ToString())
  End Sub
End Class