import java.util.*; public class Main { public static void main (String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); long max = sc.nextInt(); long min = max; for (int i = 1; i < n; i++) { long x = sc.nextInt(); long nextMax = max + x; nextMax = Math.max(nextMax, max - x); nextMax = Math.max(nextMax, max * x); nextMax = Math.max(nextMax, min + x); nextMax = Math.max(nextMax, min - x); nextMax = Math.max(nextMax, min * x); long nextMin = max + x; nextMin = Math.min(nextMin, max - x); nextMin = Math.min(nextMin, max * x); nextMin = Math.min(nextMin, min + x); nextMin = Math.min(nextMin, min - x); nextMin = Math.min(nextMin, min * x); if (x != 0) { nextMax = Math.max(nextMax, max / x); nextMax = Math.max(nextMax, min / x); nextMin = Math.min(nextMin, max / x); nextMin = Math.min(nextMin, min / x); } max = nextMax; min = nextMin; } System.out.println(max); } }