Language: C++

#include<iostream>
using namespace std;
main(){
  int n;
  cin>>n;
  vector<int>a(n);
  for(auto& ai:a)cin>>ai;
  map<int,int>cnt;
  for(auto ai:a)cnt[ai]++;
  int ans=0,t=0;
  for(auto val:cnt){
    if(val.second>=4){
      ans=max({ans,val.first*val.first,val.first*t});
    }
    if(val.second>=2){
      ans=max(ans,t*val.first);
      t=max(t,val.first);
    }
  }
  cout<<ans<<endl;
}

Compiler output:
a.cc:3:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
    3 | main(){
      | ^~~~
a.cc: In function 'int main()':
a.cc:6:3: error: 'vector' was not declared in this scope
    6 |   vector<int>a(n);
      |   ^~~~~~
a.cc:2:1: note: 'std::vector' is defined in header '<vector>'; this is probably fixable by adding '#include <vector>'
    1 | #include<iostream>
  +++ |+#include <vector>
    2 | using namespace std;
a.cc:6:10: error: expected primary-expression before 'int'
    6 |   vector<int>a(n);
      |          ^~~
a.cc:7:16: error: 'a' was not declared in this scope; did you mean 'ai'?
    7 |   for(auto& ai:a)cin>>ai;
      |                ^
      |                ai
a.cc:8:3: error: 'map' was not declared in this scope
    8 |   map<int,int>cnt;
      |   ^~~
a.cc:2:1: note: 'std::map' is defined in header '<map>'; this is probably fixable by adding '#include <map>'
    1 | #include<iostream>
  +++ |+#include <map>
    2 | using namespace std;
a.cc:8:7: error: expected primary-expression before 'int'
    8 |   map<int,int>cnt;
      |       ^~~
a.cc:9:15: error: 'a' was not declared in this scope; did you mean 'ai'?
    9 |   for(auto ai:a)cnt[ai]++;
      |               ^
      |               ai
a.cc:9:17: error: 'cnt' was not declared in this scope; did you mean 'int'?
    9 |   for(auto ai:a)cnt[ai]++;
      |                 ^~~
      |                 int
a.cc:11:16: error: 'cnt' was not declared in this scope; did you mean 'int'?
   11 |   for(auto val:cnt){
      |                ^~~
      |                int
a.cc:13:14: error: no matching function for call to 'max(<brace-enclosed initializer list>)'
   13 |       ans=max({ans,val.first*val.first,val.first*t});
      |           ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/string:51,
                 from /usr/include/c++/14/bits/locale_classes.h:40,
                 from /usr/include/c++/14/bits/ios_base.h:41,
                 from /usr/include/c++/14/ios:44,
                 from /usr/include/c++/14/ostream:40,
                 from /usr/include/c++/14/iostream:41,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  257 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:257:5: note:   candidate expects 2 arguments, 1 provided
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  303 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note:   candidate expects 3 arguments, 1 provided