import sys import math N = int(sys.stdin.readline()) list = list(map(int,sys.stdin.readline().split())) list.sort() if N == 1: print(int(math.pow(list[0],2))) else : print(list[0] * list[len(list)-1])