import std.algorithm, std.container, std.conv, std.math, std.range, std.typecons, std.stdio, std.string;

void readV(T...)(ref T t){auto r=readln.splitter;foreach(ref v;t){v=r.front.to!(typeof(v));r.popFront;}}
void readA(T)(size_t n,ref T[]t){t=new T[](n);auto r=readln.splitter;foreach(ref v;t){v=r.front.to!T;r.popFront;}}

void main()
{
  int n; readV(n);
  int[] a; readA(n, a);

  int[int] h;
  foreach (ai; a) h[ai]++;

  auto u = h.keys.sort!"a>b".filter!(ai => h[ai] >= 2).array;

  if (u.length == 0 || u.length == 1 && h[u[0]] < 4)
    writeln(0);
  else if (h[u[0]] >= 4)
    writeln(u[0].to!long^^2);
  else
    writeln(u[0].to!long*u[1]);
}
