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

~/algor $ cat problems/kombinatorika-diagonallar-soni

Number of diagonals of a polygon

Easy 1000 ms 128 MB 30%
Share

How many diagonals does a convex $n$-gon have? A diagonal is a segment joining two non-adjacent vertices.

A convex pentagon and all its diagonals

Input

One positive integer $n$.

Output

One integer — the number of diagonals.

Note

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

Examples

Input #1
5
Output #1
5
Input #2
3
Output #2
0

Sign in to submit a solution

Signing up is free and takes a minute.