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 sum=0; for(int i=1;i<5;i++) { for(int j=i;j<5;j++) { if(i==j)break; sum=sum+(A[i]*A[j]); } } long res=sum; return res; } 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(); } }