import java.util.*; public class Main { public static Scanner sc = new Scanner(System.in); public static void main(String[] args) throws Exception { int n = sc.nextInt(); int[] a = new int[n]; for (int i = 0;i < n;i++) a[i] = sc.nextInt(); long[] dp = new long[100]; dp[0] = a[0]; for (int i = 1;i < n;i++) { long tmp = Long.MIN_VALUE; tmp = Math.max(tmp, dp[i-1]+a[i]); tmp = Math.max(tmp, dp[i-1]-a[i]); tmp = Math.max(tmp, dp[i-1]*a[i]); if (a[i]!=0) tmp = Math.max(tmp, dp[i-1]/a[i]); dp[i] = tmp; } System.out.println(dp[n-1]); } }