{"trustable":false,"sections":[{"title":"","value":{"format":"HTML","content":"\u003cdiv class\u003d\"ptx\" lang\u003d\"en-US\"\u003eThe multiplication puzzle is played with a row of cards, each containing a single positive integer. During the move player takes one card out of the row and scores the number of points equal to the product of the number on the card taken and the numbers on the cards on the left and on the right of it. It is not allowed to take out the first and the last card in the row. After the final move, only two cards are left in the row.\n\u003cbr\u003e\n\u003cbr\u003eThe goal is to take cards in such order as to minimize the total number of scored points.\n\u003cbr\u003e\n\u003cbr\u003eFor example, if cards in the row contain numbers 10 1 50 20 5, player might take a card with 1, then 20 and 50, scoring\n\u003cbr\u003e\u003ccenter\u003e10*1*50 + 50*20*5 + 10*50*5 \u003d 500+5000+2500 \u003d 8000\u003c/center\u003e\n\u003cbr\u003eIf he would take the cards in the opposite order, i.e. 50, then 20, then 1, the score would be\n\u003cbr\u003e\u003ccenter\u003e1*50*20 + 1*20*5 + 10*1*5 \u003d 1000+100+50 \u003d 1150.\u003c/center\u003e\n\u003cbr\u003e给出一组N个数,每次从中抽出一个数(第一和最后一个不能抽),该次的得分即为抽出的数与相邻两个数的乘积。直到只剩下首尾两个数为止。问最小得分是多少?\u003c/div\u003e"}},{"title":"Input","value":{"format":"HTML","content":"\u003cdiv class\u003d\"ptx\" lang\u003d\"en-US\"\u003eThe first line of the input contains the number of cards N (3 \u0026lt;\u003d N \u0026lt;\u003d 100). The second line contains N integers in the range from 1 to 100, separated by spaces.\u003c/div\u003e"}},{"title":"Output","value":{"format":"HTML","content":"\u003cdiv class\u003d\"ptx\" lang\u003d\"en-US\"\u003eOutput must contain a single integer - the minimal score.\u003c/div\u003e"}},{"title":"Sample Input","value":{"format":"HTML","content":"\u003cpre class\u003d\"sio\"\u003e6\n10 1 50 50 20 5\n\u003c/pre\u003e"}},{"title":"Sample Output","value":{"format":"HTML","content":"\u003cpre class\u003d\"sio\"\u003e3650\u003c/pre\u003e"}}]}