eolymp
bolt
Try our new interface for solving problems
Problems

Minimum Triangulation

Minimum Triangulation

You are given a regular polygon with $n$ vertices labeled from $1$ to $n$ in counter-clockwise order. The triangulation of a given polygon is a set of triangles such that each vertex of each triangle is a vertex of the initial polygon, there is no pair of triangles such that their intersection has non-zero area, and the total area of all triangles is equal to the area of the given polygon. The weight of a triangulation is the sum of weigths of triangles it consists of, where the weight of a triagle is denoted as the product of labels of its vertices. Calculate the minimum weight among all triangulations of the polygon. \InputFile One integer $n~(3 \le n \le 500)$ --- the number of vertices in the regular polygon. \OutputFile Print the minimum weight among all triangulations of the given polygon. \Examples In the first test case a triangle with labels $1, 2, 3$ is given. Its weight is $1 \cdot 2 \cdot 3 = 6$. \includegraphics{https://static.eolymp.com/content/rd/rd6pdijqrl7un3a5pv4jqkppis.gif} The second test case is a square with labels $1, 2, 3, 4$. We shall get the minimum weight for a triangulation with the diagonal $(1, 3)$. It is equal to $1 \cdot 2 \cdot 3 + 1 \cdot 3 \cdot 4 = 6 + 12 = 18$.
Time limit 1 second
Memory limit 128 MiB
Input example #1
3
Output example #1
6
Input example #2
4
Output example #2
18