# 使用堆找出最大的三个和最小的两个

import sys
import heapq
import math
A = [int(i) for i in sys.stdin.read().strip().split('\n')[-1].split(' ')]

l = heapq.nlargest(3, A)
s = heapq.nsmallest(2, A)
v0 = math.prod(l)
v1 = math.prod([l[0], *s])

print(max(v0, v1))