Skip to main content
Tuesday (24.11.2026) at 20:00: ALGOR Contest: Round #4 (Special Challenge) starts!

~/algor $ cat problems/kopburchak-diagonallari

Diagonals of a polygon

Easy 1000 ms 64 MB 9%
Share

The number of vertices $n$ of a convex polygon is given. Find the number of its diagonals $D$. A diagonal is a segment joining two non-adjacent vertices:

$$D = \frac{n * (n - 3)}{2}$$

A convex hexagon: n vertices, diagonals drawn from each vertex to the non-adjacent ones

Input

One positive integer $n$.

Output

One integer — $D$.

Note

$3 \le n \le 10^{6}$

Examples

Input #1
5
Output #1
5
Input #2
4
Output #2
2

Sign in to submit a solution

Signing up is free and takes a minute.