using System; using System.Collections.Generic; using System.IO; using System.Linq; class Solution { static long largestValue(int[] A) { long maxValue = long.MinValue; for(int i = 0; i < A.Length; ++i) { for(int j = i; j < A.Length; ++j) { if(i+j < A.Length) { var subArray = A.Skip(i).Take(j+1).ToArray(); //Console.WriteLine($"{i},{j}="+ string.Join(",", subArray)); long max = GetMax(subArray); if(max > maxValue) { maxValue = max; } } } } return maxValue; } static long GetMax(int[] A) { long sum = 0; for(int i = 0; i < A.Length-1; ++i) { for(int j = 1; j < A.Length; ++j) { if(j!=i && j>i) { //Console.WriteLine($"{A[i]},{A[j]}"); sum += A[i]*A[j]; } } } //Console.WriteLine($"-----"); return sum; } static void Main(String[] args) { int n = Convert.ToInt32(Console.ReadLine()); string[] A_temp = Console.ReadLine().Split(' '); int[] A = Array.ConvertAll(A_temp,Int32.Parse); long result = largestValue(A); Console.WriteLine(result); } }