Language: C++

import java.io.*;
import java.util.*;

public class Main {
    public static void main(String[] args) throws IOException {
        InputReader in = new InputReader();
        PrintWriter out = new PrintWriter(System.out);
        int test_cases = 1;
        Solver s = new Solver();
        for (int i = 1; i <= test_cases; i++) {
            s.solve(i, in, out);
        }
        out.close();
    }
}

class Solver {
    void solve(int test_number, InputReader in, PrintWriter out) throws IOException {
        int n = in.nextInt();
        HashMap<Long, Integer> map = new HashMap<>();
        for (int i = 0; i < n; i++) {
            long x = in.nextLong();
            if (map.get(x) != null) {
                map.put(x, map.get(x) + 1);
            } else map.put(x, 1);
        }
        ArrayList<Long> v = new ArrayList<>();
        for (Map.Entry<Long, Integer> entry : map.entrySet()) {
            if (entry.getValue() > 1) v.add(entry.getKey());
        }
        if (v.size() > 1) {
            Collections.sort(v);
            out.println(v.get(v.size() - 1) * v.get(v.size() - 2));
        }
        else out.println(0);
    }
}


class InputReader {
    BufferedReader br;
    StringTokenizer st;

    public InputReader()
    {
        br = new BufferedReader(new
                InputStreamReader(System.in));
    }

    String next()
    {
        while (st == null || !st.hasMoreElements())
        {
            try
            {
                st = new StringTokenizer(br.readLine());
            }
            catch (IOException  e)
            {
                e.printStackTrace();
            }
        }
        return st.nextToken();
    }

    int nextInt()
    {
        return Integer.parseInt(next());
    }

    long nextLong()
    {
        return Long.parseLong(next());
    }

    double nextDouble()
    {
        return Double.parseDouble(next());
    }

    String nextLine()
    {
        String str = "";
        try
        {
            str = br.readLine();
        }
        catch (IOException e)
        {
            e.printStackTrace();
        }
        return str;
    }
}

Compiler output:
a.cc:1:1: error: 'import' does not name a type
    1 | import java.io.*;
      | ^~~~~~
a.cc:1:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:2:1: error: 'import' does not name a type
    2 | import java.util.*;
      | ^~~~~~
a.cc:2:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:4:1: error: expected unqualified-id before 'public'
    4 | public class Main {
      | ^~~~~~
a.cc:18:33: error: 'InputReader' has not been declared
   18 |     void solve(int test_number, InputReader in, PrintWriter out) throws IOException {
      |                                 ^~~~~~~~~~~
a.cc:18:49: error: 'PrintWriter' has not been declared
   18 |     void solve(int test_number, InputReader in, PrintWriter out) throws IOException {
      |                                                 ^~~~~~~~~~~
a.cc:18:64: error: expected ';' at end of member declaration
   18 |     void solve(int test_number, InputReader in, PrintWriter out) throws IOException {
      |                                                                ^
      |                                                                 ;
a.cc:18:66: error: 'throws' does not name a type
   18 |     void solve(int test_number, InputReader in, PrintWriter out) throws IOException {
      |                                                                  ^~~~~~
a.cc:37:2: error: expected ';' after class definition
   37 | }
      |  ^
      |  ;
a.cc:41:5: error: 'BufferedReader' does not name a type
   41 |     BufferedReader br;
      |     ^~~~~~~~~~~~~~
a.cc:42:5: error: 'StringTokenizer' does not name a type
   42 |     StringTokenizer st;
      |     ^~~~~~~~~~~~~~~
a.cc:44:11: error: expected ':' before 'InputReader'
   44 |     public InputReader()
      |           ^~~~~~~~~~~~
      |           :
a.cc:50:5: error: 'String' does not name a type
   50 |     String next()
      |     ^~~~~~
a.cc:81:5: error: 'String' does not name a type
   81 |     String nextLine()
      |     ^~~~~~
a.cc:94:2: error: expected ';' after class definition
   94 | }
      |  ^
      |  ;
a.cc: In constructor 'InputReader::InputReader()':
a.cc:46:9: error: 'br' was not declared in this scope
   46 |         br = new BufferedReader(new
      |         ^~
a.cc:46:18: error: expected type-specifier before 'BufferedReader'
   46 |         br = new BufferedReader(new
      |                  ^~~~~~~~~~~~~~
a.cc: In member function 'int InputReader::nextInt()':
a.cc:68:16: error: 'Integer' was not declared in this scope
   68 |         return Integer.parseInt(next());
      |                ^~~~~~~
a.cc:68:33: error: 'next' was not declared in this scope; did you mean 'nextInt'?
   68 |         return Integer.parseInt(next());
      |                                 ^~~~
      |                                 nextInt
a.cc: In member function 'long int InputReader::nextLong()':
a.cc:73:16: error: 'Long' was not declared in this scope; did you mean 'long'?
   73 |         return Long.parseLong(next());
      |                ^~~~
      |                long
a.cc:73:31: error: 'next' was not declared in this scope; did you mean 'nextInt'?
   73 |         return Long.parseLong(next());
      |                               ^~~~
      |                               nextInt
a.cc: In member function 'double InputReader::nextDouble()':
a.cc:78:16: error: 'Double' was not declared in this scope; did you mean 'double'?
   78 |         return Double.parseDouble(next());
      |                ^~~~~~
      |                double
a.cc:78:35: error: 'next' was not declared in this scope; did you mean 'nextInt'?
   78 |         return Double.parseDouble(next());
      |                                   ^~~~
      |                                   nextInt