import
java.io.*;
import
java.util.*;
class
GFG
{
static
int
findProduct(
int
number_1,
int
number_2)
{
if
(number_1 == Integer.MIN_VALUE || number_2 == Integer.MIN_VALUE)
{
return
0
;
}
else
return
number_1 * number_2;
}
static
ArrayList<Integer> calculateProduct(ArrayList<ArrayList<Integer>> List,
int
index)
{
int
highest = Collections.max(List.get(index));
int
lowest = Collections.min(List.get(index));
if
(index +
1
== List.size())
{
if
(lowest <
0
&& highest >=
0
)
{
return
(
new
ArrayList<Integer>(Arrays.asList(highest, lowest)));
}
else
if
(lowest <=
0
&& highest <=
0
)
{
return
(
new
ArrayList<Integer>(Arrays.asList(Integer.MIN_VALUE, lowest)));
}
else
if
(lowest >=
0
&& highest >=
0
)
{
return
(
new
ArrayList<Integer>(Arrays.asList(highest,Integer.MIN_VALUE)));
}
}
ArrayList<Integer> temp = calculateProduct(List, index +
1
);
int
positive = temp.get(
0
);
int
negative = temp.get(
1
);
int
highPos = findProduct(highest, positive);
int
highNeg = findProduct(highest, negative);
int
lowPos = findProduct(lowest, positive);
int
lowNeg = findProduct(lowest, negative);
if
(lowest <
0
&& highest >=
0
)
{
return
(
new
ArrayList<Integer>(Arrays.asList(Math.max(highPos, lowNeg), Math.min(highNeg, lowPos))));
}
else
if
(lowest <=
0
&& highest <=
0
)
{
return
(
new
ArrayList<Integer>(Arrays.asList(lowNeg, lowPos)));
}
else
if
(lowest >=
0
&& highest >=
0
)
{
return
(
new
ArrayList<Integer>(Arrays.asList(Math.max(lowPos, highPos), Math.min(lowNeg, highNeg))));
}
return
(
new
ArrayList<Integer>(Arrays.asList(
0
,
0
)));
}
public
static
void
main (String[] args) {
int
N =
2
;
ArrayList<ArrayList<Integer>> arr =
new
ArrayList<ArrayList<Integer>>();
arr.add(
new
ArrayList<Integer>(Arrays.asList(-
3
, -
4
)));
arr.add(
new
ArrayList<Integer>(Arrays.asList(
1
,
2
, -
3
)));
ArrayList<Integer> ans = calculateProduct(arr,
0
);
System.out.println(ans.get(
0
));
}
}