program main
	implicit none
	integer(4) ::times=1,n,a(100000)=0,i,j,dum,b(50000)=0
	integer(8) res,tate,yoko
	read(*,*)n
	read(*,*)a(1:n)
	do i=1,n
		dum=a(i)
		do j=i+1,n
			if(a(j)<1000000000)then
				if(dum==a(j))then
					b(times)=dum
					a(j)=a(j)+1000000000
					times=times+1
				endif
			endif
		enddo
	enddo
	tate=maxval(b(1:times))
	do i=1,times
		if(b(i)==tate)b(i)=0
	enddo
	yoko=maxval(b(1:times))
	res=tate*yoko
	write(*,*)res
end program main
