{"trustable":false,"sections":[{"title":"","value":{"format":"HTML","content":"\u003cdiv class\u003d\"ptx\" lang\u003d\"en-US\"\u003e\r\n\tThe 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.\u003cbr /\u003e\r\n\t\u003cbr /\u003e\r\n\tThe goal is to take cards in such order as to minimize the total number of scored points.\u003cbr /\u003e\r\n\t\u003cbr /\u003e\r\n\tFor 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\u003cbr /\u003e\r\n\t\u003ccenter\u003e\r\n\t\t10*1*50 + 50*20*5 + 10*50*5 \u003d 500+5000+2500 \u003d 8000\u003c/center\u003e\r\n\t\u003cbr /\u003e\r\n\tIf he would take the cards in the opposite order, i.e. 50, then 20, then 1, the score would be\u003cbr /\u003e\r\n\t\u003ccenter\u003e\r\n\t\t1*50*20 + 1*20*5 + 10*1*5 \u003d 1000+100+50 \u003d 1150.\u003c/center\u003e\r\n\u003c/div\u003e"}},{"title":"Input","value":{"format":"HTML","content":"\u003cdiv class\u003d\"ptx\" lang\u003d\"en-US\"\u003e\r\n\tThe 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\"\u003e\r\n\tOutput must contain a single integer - the minimal score.\u003c/div\u003e"}},{"title":"Sample Input","value":{"format":"HTML","content":"\u003cpre class\u003d\"sio\"\u003e\r\n6\r\n10 1 50 50 20 5\r\n\u003c/pre\u003e"}},{"title":"Sample Output","value":{"format":"HTML","content":"\u003cpre class\u003d\"sio\"\u003e\r\n3650\u003c/pre\u003e"}},{"title":"Hint","value":{"format":"HTML","content":"\u003cp\u003e\r\n\t\u003cspan data-scayt_word\u003d\"参考课本6\" data-scaytid\u003d\"1\"\u003e参考课本6\u003c/span\u003e.5节\u003c/p\u003e"}}]}