import java.util.Scanner; // 注意类名必须为 Main, 不要有任何 package xxx 信息 public class Main { public static void main(String[] args) { Scanner in = new Scanner(System.in); // DP7 连续子数组的最大乘积 int n = in.nextInt(); int max = 0; int all = 1; int left = 1; int right = 1; boolean hasLeft = false; boolean hasRight = false; if (n > 1) { for (int i = 0; i < n; i++) { int x = in.nextInt(); max = (max > x) ? max : x; if (x == 0) { all = 1; left = 1; right = 1; hasLeft = false; hasRight = false; } else { all *= x; max = (max > all) ? max : all; if (all < 0) { if (!hasLeft) { hasLeft = true; left = all; } else { int num = all / left; max = (max > num) ? max : num; } if (!hasRight && x < 0) { hasRight = true; right = x; } else if (hasRight && x > 0) { right *= x; int num = all / right; max = (max > num) ? max : num; } else { right = 1; } } } } }else{ max = in.nextInt(); } System.out.println(max); } }