Petrol Stations

Time limit: 0.05s Memory limit: 64MB Input: Output:

In Piatra Neamt City there are N+2N+2 locations labeled from 00 to N+1N+1, from left to right. The distance between two locations ii and jj is equal to ij|i – j|.

At the beginning, in the locations 00 and N+1N+1, petrol stations are built, and in the other locations there are houses.

The company BuildNT has decided to build NN petrol stations, one in front of each house.

Before building a petrol station, the constructors calculate the value SS equal to the sum of the distances from each house to the nearest petrol station, and add this sum to a total sum TT. Then, they choose a house, at the maximum distance of any petrol station, in front of which they will build a new petrol station. The house is chosen in such a way that, after the construction of the petrol station, the recalculated value of SS should be the minimum possible. If there are more such houses, the first one on the left will be chosen.

Task

Of course, after all the petrol stations are built, the sum SS will become 00 and the total sum TT will no longer change. Your task is to calculate TT for a given NN.

Input data

The first line contains only one number NN – the number of houses.

Output data

Display a single number – the total sum TT after the NN petrol stations have been built.

Constraints and clarifications

  • 1N1 000 000 0001 \leq N \leq 1 \ 000 \ 000 \ 000
  • For 30%30\% of testcases, N10 000N \leq 10 \ 000.
  • For other 30%30\% of testcases, N1 000 000N \leq 1 \ 000 \ 000.

Example

stdin

12

stdout

124

Explanation

In the table below, there is an explanation for calculating TT for N=12N=12. The first column contains the distances from every location (including the locations 00 and N+1=13N+1=13) to the closest petrol station.

Distances for all locations SS TT The location where a petrol station is built
0 1 2 3 4 5 6 6 5 4 3 2 1 00 \ 1 \ 2 \ 3 \ 4 \ 5 \ 6 \ 6 \ 5 \ 4 \ 3 \ 2 \ 1 \ 0 4242 4242 66
0 1 2 3 2 1 0 1 2 3 3 2 1 00 \ 1 \ 2 \ 3 \ 2 \ 1 \ 0 \ 1 \ 2 \ 3 \ 3 \ 2 \ 1 \ 0 2121 6363 99
0 1 2 3 2 1 0 1 1 0 1 2 1 00 \ 1 \ 2 \ 3 \ 2 \ 1 \ 0 \ 1 \ 1 \ 0 \ 1 \ 2 \ 1 \ 0 1515 7878 33
0 1 1 0 1 1 0 1 1 0 1 2 1 00 \ 1 \ 1 \ 0 \ 1 \ 1 \ 0 \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