import std.stdio;
import std.string;
import std.conv;
import std.algorithm;
import std.math;
import std.regex;

void main() {
	auto N = readln.chomp.to!int;
	auto A = readln.split.to!(int[]);
	int[2] lines;
	foreach(A_i; A.uniq.array) {
		if(A.count!A_i >= 2) {
			if(A_i > lines[0]) {
				lines[1] = lines[0];
				lines[0] = A_i;
	 		} else if(A_i > lines[1]) {
	 			lines[1] = A_i;
	 		}
		}
	}
	if(lines.count!0 > 0) writeln(-1);
	else writeln(lines[0] * lines[1]);
}