using System; using System.Collections.Generic; using System.IO; using System.Linq; class Solution { static long largestValue(int[] a) { // Return the largest value of any of A's nonempty subarrays. int max = int.MinValue; for (int i = 0; i < a.Length; i++){ int sum = a[i]; int prev = 0; int total = 0; for (int j = i + 1; j < a.Length; j++){ total = prev + sum * a[j]; prev = total; sum += a[j]; max = Math.Max(max,total); } } return max; } 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); } }