#Q151. 「一本通 5.1 例 3」凸多边形的划分

「一本通 5.1 例 3」凸多边形的划分

Description

Given a convex polygon with NN vertices, labeled from 11 to NN, each vertex has a positive integer weight. Divide this convex polygon into N2N-2 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 NN.

The second line lists the weights of vertex 11 through vertex NN 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 100%100\% of the data, N50N\le 50, and each vertex weight is less than 10910^9.