import java.util.*;


public class Solution {
    /**
     * 最大乘积
     * @param A int整型一维数组 
     * @return long长整型
     */
    public long solve (int[] A) {
        // write code here
        Arrays.sort(A);
        return 1L*A[0]*A[1]*A[A.length-1]>1L*A[A.length-1]*A[A.length-2]*A[A.length-3]?
            1L*A[0]*A[1]*A[A.length-1]:1L*A[A.length-1]*A[A.length-2]*A[A.length-3];
        
    }
}