import std.stdio,
       std.string,
       std.conv,
       std.algorithm;

void main() {
  int N = readln.chomp.to!(int);
  long[] A = readln.chomp.split.to!(long[]);
  sort(A);

  long max_, cnt, now;
  for (int i = N - 1; i >= 0; i--) {
    if (now == A[i]) {
      cnt++;
    }
    else {
      now = A[i];
      cnt = 1;
    }

    if (cnt == 4) {
      writeln(now * now);
      return;
    }
    else if (cnt == 2) {
      if (max_ != 0) {
        writeln(now * max_);
        return;
      }
      else {
        max_ = max(max_, now);
      }
    }
  }

  writeln(0);
}
