#Q151. 「一本通 5.1 例 3」凸多边形的划分
「一本通 5.1 例 3」凸多边形的划分
Description
Given a convex polygon with vertices, labeled from to , each vertex has a positive integer weight. Divide this convex polygon into non-intersecting triangles. Find the minimum possible sum of the products of the vertices' weights for these triangles.
Input Format
The first line of input contains the number of vertices .
The second line lists the weights of vertex through vertex in order.
Output Format
Output a single line containing the minimum sum of the products of the vertices' weights for the triangles.
Sample 1
5
121 122 123 245 231
12214884
Constraints and Hints
For of the data, , and each vertex weight is less than .