100 atcoder#ABC139D. [ABC139D] ModSum

[ABC139D] ModSum

Score : 400400 points

Problem Statement

For an integer NN, we will choose a permutation {P1,P2,...,PN}\{P_1, P_2, ..., P_N\} of {1,2,...,N}\{1, 2, ..., N\}.

Then, for each i=1,2,...,Ni=1,2,...,N, let MiM_i be the remainder when ii is divided by PiP_i.

Find the maximum possible value of M1+M2++MNM_1 + M_2 + \cdots + M_N.

Constraints

  • NN is an integer satisfying 1N1091 \leq N \leq 10^9.

Input

Input is given from Standard Input in the following format:

NN

Output

Print the maximum possible value of M1+M2++MNM_1 + M_2 + \cdots + M_N.

2
1

When the permutation {P1,P2}={2,1}\{P_1, P_2\} = \{2, 1\} is chosen, M1+M2=1+0=1M_1 + M_2 = 1 + 0 = 1.

13
78
1
0