def mcs(a, low, mid, high): left_s = -(10 ** 7) s = 0 max_left, max_right = -1, -1 for i in range(mid, low - 1, -1): s = s + a[i] if (s > left_s): left_s = s max_left = i s = 0 right_s = -(10 ** 7) for j in range(mid + 1, high + 1): s = s + a[j] if (s > right_s): right_s = s max_right = j return (max_left, max_right, left_s + right_s) def ms(a, low, high): if (high == low): return (low, high, a[low]) else: mid = (low + high) // 2 left_low, left_high, left_sum =ms(a,low,mid) right_low, right_high, right_sum = ms(a, mid + 1, high) cross_low, cross_high, cross_sum = mcs(a, low, mid, high) if (left_sum >= right_sum and left_sum >= cross_sum): return (left_low, left_high, left_sum) elif (right_sum >= left_sum and right_sum >= cross_sum): return (right_low, right_high, right_sum) else: return (cross_low, cross_high, cross_sum) x = list(map(int, input().split())) a = list(map(int, input().split())) b,c,d=ms(a,0,len(a)-1) a=a[b:c+1] p=0 for i in range(len(a)-1): for j in range(i+1,len(a)): p=p+(a[i]*a[j]) print(p)