import java.util.*; public class Main { public static void main (String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); long max = 0; long min = 0; for (int i = 0; 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); max = nextMax; min = nextMin; } System.out.println(max); } }