import java.util.*; public class Main{ public static void main(String[] args){ try(Scanner sc = new Scanner(System.in)){ int N = sc.nextInt(), num = 0, now; for(int i = 0; i < N; i++){ now = Math.abs(sc.nextInt()); num = Math.max(num + now, num * now); } System.out.println(num); } } }