Public Class Program
  Shared Sub Main()
    Dim n As Long = Long.Parse(Console.ReadLine())
    Dim ans As Long = 0
    If n <> 1 Then ans = (n - 1) * n / 2
    Console.WriteLine(ans.ToString())
  End Sub
End Class