import java.util.Scanner; public class Main_yukicoder276 { public static void main(String[] args) { Scanner sc = new Scanner(System.in); long n = sc.nextLong(); if (n == 1) { System.out.println("1"); } else { System.out.println(n * (n - 1) / 2); } sc.close(); } }