import core.bitop;
import std.algorithm;
import std.array;
import std.ascii;
import std.container;
import std.conv;
import std.format;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

long dfs(in long[] p, long[] arr, int bits, int depth)
{
  if (depth == 4) {
    return min(arr[0], arr[1]) * min(arr[2], arr[3]);
  }
  long ans = 0;
  foreach (i; 0..4) {
    if ((bits >> i) & 1) {
      continue;
    }
    arr[depth] = p[i];
    ans = max(ans, dfs(p, arr, bits | 1 << i, depth + 1));
  }
  return ans;
}

void main()
{
  int n = readln.chomp.to!int;
  long[] a = readln.chomp.split.map!(to!long).array;
  int[long] cnt;
  foreach (v; a) {
    cnt[v]++;
  }
  a = a.sort.uniq.retro.array;
  long ans = 1;
  bool done = false;
  foreach (v; a) {
    if (cnt[v] < 2) {
      continue;
    }
    if (cnt[v] >= 4) {
      ans *= v * v;
      ans.writeln;
      return;
    }
    if (done) {
      ans *= v;
      ans.writeln;
      return;
    }
    ans *= v;
    done |= true;
  }
  0.writeln;
}
