Language: C++

#include <iostream>
#include <vector>
#include <string>
#include <vector>
#include <set>
#include <map>
using namespace std;

#define ll long long

int main(){
    ll N,tmp;
    ll ans1=0, ans2=0;
    map<ll,ll> cnt;
    cin >> N;
    set<ll,ll> st(N);
    // vector<int> A(N);
    // vector<int> v;
    // for(int i = 0; i < N; i++){
    //     cin >> A[i];
    // }
    // sort(v.begin(),v.end(), greater<ll>());

    // cout << v[0]*v[1]

    for(int i = 0; i < N; i++){
        cin >> tmp;
        if(st.count(tmp) == 0){
            st.insert(tmp);
        }else if(st.count(tmp) > 2){
            st.insert(tmp);
            ans2 = max(ans2, tmp);
            if(ans1 < ans2){
                long long t = ans1;
                ans1 = ans2;
                ans2 = t;
            }   
        }else{
            if(tmp != ans1 && tmp != ans2){
                st.insert(tmp);
                ans2 = max(ans2, tmp);
                if(ans1 < ans2){
                    long long t = ans1;
                    ans1 = ans2;
                    ans2 = t;
                }
            }
        }
    }
    cout << 1LL * ans1 * ans2 << endl;
}

Compiler output:
In file included from /usr/include/c++/14/set:62,
                 from a.cc:5:
/usr/include/c++/14/bits/stl_tree.h: In instantiation of 'std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::const_iterator std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::find(const _Key&) const [with _Key = long long int; _Val = long long int; _KeyOfValue = std::_Identity<long long int>; _Compare = long long int; _Alloc = std::allocator<long long int>; const_iterator = std::_Rb_tree<long long int, long long int, std::_Identity<long long int>, long long int, std::allocator<long long int> >::const_iterator]':
/usr/include/c++/14/bits/stl_set.h:751:25:   required from 'std::set<_Key, _Compare, _Alloc>::size_type std::set<_Key, _Compare, _Alloc>::count(const key_type&) const [with _Key = long long int; _Compare = long long int; _Alloc = std::allocator<long long int>; size_type = long unsigned int; key_type = long long int]'
  751 |       { return _M_t.find(__x) == _M_t.end() ? 0 : 1; }
      |                ~~~~~~~~~^~~~~
a.cc:28:20:   required from here
   28 |         if(st.count(tmp) == 0){
      |            ~~~~~~~~^~~~~
/usr/include/c++/14/bits/stl_tree.h:2545:40: error: expression cannot be used as a function
 2545 |               || _M_impl._M_key_compare(__k,
      |                  ~~~~~~~~~~~~~~~~~~~~~~^~~~~
 2546 |                                         _S_key(__j._M_node))) ? end() : __j;
      |                                         ~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_tree.h: In instantiation of 'std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::const_iterator std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::_M_lower_bound(_Const_Link_type, _Const_Base_ptr, const _Key&) const [with _Key = long long int; _Val = long long int; _KeyOfValue = std::_Identity<long long int>; _Compare = long long int; _Alloc = std::allocator<long long int>; const_iterator = std::_Rb_tree<long long int, long long int, std::_Identity<long long int>, long long int, std::allocator<long long int> >::const_iterator; _Const_Link_type = const std::_Rb_tree_node<long long int>*; _Const_Base_ptr = const std::_Rb_tree_node_base*]':
/usr/include/c++/14/bits/stl_tree.h:2543:42:   required from 'std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::const_iterator std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::find(const _Key&) const [with _Key = long long int; _Val = long long int; _KeyOfValue = std::_Identity<long long int>; _Compare = long long int; _Alloc = std::allocator<long long int>; const_iterator = std::_Rb_tree<long long int, long long int, std::_Identity<long long int>, long long int, std::allocator<long long int> >::const_iterator]'
 2543 |       const_iterator __j = _M_lower_bound(_M_begin(), _M_end(), __k);
      |                            ~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_set.h:751:25:   required from 'std::set<_Key, _Compare, _Alloc>::size_type std::set<_Key, _Compare, _Alloc>::count(const key_type&) const [with _Key = long long int; _Compare = long long int; _Alloc = std::allocator<long long int>; size_type = long unsigned int; key_type = long long int]'
  751 |       { return _M_t.find(__x) == _M_t.end() ? 0 : 1; }
      |                ~~~~~~~~~^~~~~
a.cc:28:20:   required from here
   28 |         if(st.count(tmp) == 0){
      |            ~~~~~~~~^~~~~
/usr/include/c++/14/bits/stl_tree.h:1964:36: error: expression cannot be used as a function
 1964 |         if (!_M_impl._M_key_compare(_S_key(__x), __k))
      |              ~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_tree.h: In instantiation of 'std::pair<std::_Rb_tree_node_base*, std::_Rb_tree_node_base*> std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::_M_get_insert_unique_pos(const key_type&) [with _Key = long long int; _Val = long long int; _KeyOfValue = std::_Identity<long long int>; _Compare = long long int; _Alloc = std::allocator<long long int>; key_type = long long int]':
/usr/include/c++/14/bits/stl_tree.h:2169:4:   required from 'std::pair<std::_Rb_tree_iterator<_Val>, bool> std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::_M_insert_unique(_Arg&&) [with _Arg = const long long int&; _Key = long long int; _Val = long long int; _KeyOfValue = std::_Identity<long long int>; _Compare = long long int; _Alloc = std::allocator<long long int>]'
 2169 |         = _M_get_insert_unique_pos(_KeyOfValue()(__v));
      |           ^~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_set.h:514:25:   required from 'std::pair<typename std::_Rb_tree<_Key, _Key, std::_Identity<_Tp>, _Compare, typename __gnu_cxx::__alloc_traits<_Alloc>::rebind<_Key>::other>::const_iterator, bool> std::set<_Key, _Compare, _Alloc>::insert(const value_type&) [with _Key = long long int; _Compare = long long int; _Alloc = std::allocator<long long int>; typename std::_Rb_tree<_Key, _Key, std::_Identity<_Tp>, _Compare, typename __gnu_cxx::__alloc_traits<_Alloc>::rebind<_Key>::other>::const_iterator = std::_Rb_tree<long long int, long long int, std::_Identity<long long int>, long long int, std::allocator<long long int> >::const_iterator; typename __gnu_cxx::__alloc_traits<_Alloc>::rebind<_Key>::other = std::allocator<long long int>; typename __gnu_cxx::__alloc_traits<_Alloc>::rebind<_Key> = __gnu_cxx::__alloc_traits<std::allocator<long long int>, long long int>::rebind<long long int>; typename _Alloc::value_type = long long int; value_type = long long int]'
  514 |           _M_t._M_insert_unique(__x);
      |           ~~~~~~~~~~~~~~~~~~~~~^~~~~
a.cc:29:22:   required from here
   29 |             st.insert(tmp);
      |             ~~~~~~~~~^~~~~
/usr/include/c++/14/bits/stl_tree.h:2116:42: error: expression cannot be used as a function
 2116 |           __comp = _M_impl._M_key_compare(__k, _S_key(__x));
      |                    ~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_tree.h:2127:33: error: expression cannot be used as a function
 2127 |       if (_M_impl._M_key_compare(_S_key(__j._M_node), __k))
      |           ~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_tree.h: In instantiation of 'std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::iterator std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::_M_insert_(_Base_ptr, _Base_ptr, _Arg&&, _NodeGen&) [with _Arg = const long long int&; _NodeGen = std::_Rb_tree<long long int, long long int, std::_Identity<long long int>, long long int, std::allocator<long long int> >::_Alloc_node; _Key = long long int; _Val = long long int; _KeyOfValue = std::_Identity<long long int>; _Compare = long long int; _Alloc = std::allocator<long long int>; iterator = std::_Rb_tree<long long int, long long int, std::_Identity<long long int>, long long int, std::allocator<long long int> >::iterator; _Base_ptr = std::_Rb_tree_node_base*]':
/usr/include/c++/14/bits/stl_tree.h:2174:26:   required from 'std::pair<std::_Rb_tree_iterator<_Val>, bool> std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::_M_insert_unique(_Arg&&) [with _Arg = const long long int&; _Key = long long int; _Val = long long int; _KeyOfValue = std::_Identity<long long int>; _Compare = long long int; _Alloc = std::allocator<long long int>]'
 2174 |           return _Res(_M_insert_(__res.first, __res.second,
      |                       ~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
 2175 |                                  _GLIBCXX_FORWARD(_Arg, __v), __an),
      |                                  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_set.h:514:25:   required from 'std::pair<typename std::_Rb_tree<_Key, _Key, std::_Identity<_Tp>, _Compare, typename __gnu_cxx::__alloc_traits<_Alloc>::rebind<_Key>::other>::const_iterator, bool> std::set<_Key, _Compare, _Alloc>::insert(const value_type&) [with _Key = long long int; _Compare = long long int; _Alloc = std::allocator<long long int>; typename std::_Rb_tree<_Key, _Key, std::_Identity<_Tp>, _Compare, typename __gnu_cxx::__alloc_traits<_Alloc>::rebind<_Key>::other>::const_iterator = std::_Rb_tree<long long int, long long int, std::_Identity<long long int>, long long int, std::allocator<long long int> >::const_iterator; typename __gnu_cxx::__alloc_traits<_Alloc>::rebind<_Key>::other = std::allocator<long long int>; typename __gnu_cxx::__alloc_traits<_Alloc>::rebind<_Key> = __gnu_cxx::__alloc_traits<std::allocator<long long int>, long long int>::rebind<long long int>; typename _Alloc::value_type = long long int; value_type = long long int]'
  514 |           _M_t._M_insert_unique(__x);
      |           ~~~~~~~~~~~~~~~~~~~~~^~~~~
a.cc:29:22:   required from here
   29 |             st.insert(tmp);
      |             ~~~~~~~~~^~~~~
/usr/include/c++/14/bits/stl_tree.h:1824:56: error: expression cannot be used as a function
 1824 |                               || _M_impl._M_key_compare(_KeyOfValue()(__v),
      |                                  ~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~
 1825 |                                                         _S_key(__p)));
      |                                                         ~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_tree.h: In instantiation of 'static const _Key& std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::_S_key(_Const_Link_type) [with _Key = long long int; _Val = long long int; _KeyOfValue = std::_Identity<long long int>; _Compare = long long int; _Alloc = std::allocator<long long int>; _Const_Link_type = const std::_Rb_tree_node<long long int>*]':
/usr/include/c++/14/bits/stl_tree.h:1964:36:   required from 'std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::const_iterator std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::_M_lower_bound(_Const_Link_type, _Const_Base_ptr, const _Key&) const [with _Key = long long int; _Val = long long int; _KeyOfValue = std::_Identity<long long int>; _Compare = long long int; _Alloc = std::allocator<long long int>; const_iterator = std::_Rb_tree<long long int, long long int, std::_Identity<long long int>, long long int, std::allocator<long long int> >::const_iterator; _Const_Link_type = const std::_Rb_tree_node<long long int>*; _Const_Base_ptr = const std::_Rb_tre