      PROGRAM piyoD
      IMPLICIT NONE
      integer(16) :: n
      
      read*,n
      
      print*,n*(n-1)/2
      
      
      !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!??????????????????
      !/????????????????????????????????????????//????
      !???????????????????????????????????????????????
      !??わからん
      
      END PROGRAM