import sys def max_mat(a,n): global result2 global index a.sort() for i in range(n): if a[i]>=0: index=i break else: pass if n>=3: result1= a[-1]*a[-2]*a[-3] if index>1: result2=a[0]*a[1]*a[-1] else: result2=result1-1 if result1>result2: return result1 else: return result2 else: return None for line in sys.stdin: a = list(map(int,line.split())) if len(a)>1: n=len(a) print(max_mat(a,n))