import std.functional,
       std.algorithm,
       std.bigint,
       std.string,
       std.traits,
       std.array,
       std.range,
       std.stdio,
       std.conv;

void main() {
  int n = readln.chomp.to!int;
  int[] a = readln.chomp.split.to!(int[]);
  int[int] h;

  foreach (e; a) {
    if (e !in h) {
      h[e] = 1;
    } else {
      h[e]++;
    }
  }

  int[] b;
  foreach (k, v; h) {
    if (v % 2 == 0) {
      foreach (_; 0..v) { b ~= k; }
    }
  }
  b = b.sort!"a>b".array;

  if (b.length < 4) {
    writeln(0);
  } else {
    writeln(b[0]*b[1]*b[3]*b[4]);
  }
}

