import java.io.*; import java.util.*; import java.text.*; import java.math.*; import java.util.regex.*; public class Solution { static long largestValue(int[] A) { // Return the largest value of any of A's nonempty subarrays. int n = A.length; if (n == 0) return 0; if (n == 1) return A[0]; long[][] sum = new long[n][n]; long[][] ss = new long[n][n]; long max = 0; for (int i = 1; i < n; i++) { for (int j = 0; j < n - i; j++) { int x = j; int y = j + i; if (x == y - 1) { sum[x][y] = A[x] + A[y]; ss[x][y] = A[x] * A[x] + A[y] * A[y]; } else { sum[x][y] = sum[x][y - 1] + A[y]; ss[x][y] = ss[x][y - 1] + A[y] * A[y]; } max = Math.max(max, (sum[x][y] * sum[x][y] - ss[x][y]) / 2); } } return max; } public static void main(String[] args) { Scanner in = new Scanner(System.in); int n = in.nextInt(); int[] A = new int[n]; for(int A_i = 0; A_i < n; A_i++){ A[A_i] = in.nextInt(); } long result = largestValue(A); System.out.println(result); in.close(); } }