#!/bin/python3 import sys from itertools import combinations def getvalue(arr): a = combinations(arr,2) l = list(map(lambda x: x[0]*x[1], a)) return sum(l) def largestValue(A): # Return the largest value of any of A's nonempty subarrays. res = set() for i in range(len(A)): myA = A[:i] + A[i+1:] res.add(getvalue(myA)) return max(res) if __name__ == "__main__": n = int(input().strip()) A = list(map(int, input().strip().split(' '))) result = largestValue(A) print(result)