/*
とりあえずソースコード見る前に推し見ていってください。
                                                                                   ` ....J&wZTUUWc
                                                                             `...JZY"!~-._<~~~~_d'
                                                                       ` ..-Z"=~`..._~___::~~~_J\
       ........                                                    ` ..dY=````..~~__::::::::~_J\
  .KY"=<<<<<<<?77"YTXa-..                                      `  .JY=`````.-<~--::<<~~~~<:<_d^
   W,~~~_______<~-..`.. ?7TG+...`         ` ` `  `   ....   `  .v"~`````.-<~-JT1__........_-d'
    T,_~:::;:<z+-~~~~<-..``.`._?TSJ.. ..JVYT7TTTTTY"=<<<?7"TQJ=~`.``...?~~__(<~_......... .#`
     (h_~:<::((+v___._.~~?<.`````.`_?TG-__...___.__....` ..?~```.` .J!~~_..-~<7_......._ .P
      .W,_~~~_?71-.````` _~~?i..````````.``.```..```````._```.. .J>_~_`   ?<<__.......  (%
        ?p _..._._-z.,  ``` _~_?<- .`.````````````.``.````` _<1>_~~~~._ --(i-......._ .V!
         .W, ......(>~<~+-....~~~(t<!`.`.`.`.``.```.``.``` `   .<-~~((?1~?=_......_ .J=
           7e .........!_.C~-(>(?`  ` ````````````````````  `     ?(~_`` ``....  `.-Y
            .W, .......```` ~(<`   ` `   ` ``````````      `  `     ?-_.    ``` .J"
             `?h.     ` ` .~J! ` `     `  `   ` ` `   `  `   `  `  `  1__    ..J=
                7a,     .~_J`     ` ` `  ` ``   `  `  `   `    `  `  ` 1-_ (d=`
                  ?TGgJ<<_J`` ` `  ` - `  ```` ``` `  `(   `  `     ` .wWc<W_
                      .5g-$`   `     >  `````  ``` ` ` (-  `    `  `   _7HHXb.
                       .@H=`     ` `.l` ````  `  ```` `(<-`  _ `  `   `  j ?NHm,`
                    `.dHMF ` ` ` . `.$```` `    `` ````(~(.(<J- `  ` `   (  W7HHm,
                   `.@Ht,P` `   ._  (1_. `  ` `   `` .(T!_<-`?W+  `  ````(  d, (UHh.`
                `  .M#!  b``  ` ,Sv7TOo.  `  `   ` _~. <`` <. ({`  `` ` .<   h   .UH&`
                 `.MD`   O-`````vl  v.1__ ``` ``````.;.:``` 1 J1 ` ````.i! ` J;    ?Mh.
                 .WF     .n...``.?- > ->.-`````````..I+.`` ..e:(- . ```.V-  `.b      UN. `
                `(F      (C<~(<..l(1c` ?z1---....._jjA.JJadHYW@.> < ``.c(} `  d.      ?N.
               `.@`     .@  <((-_vM#HmQmq8?1&-~~~(J!`  WHMHMb `.>.> ._J~(!` ``(]       ,b   `
                ,>      d!`  ` v+(_`.HHMMb. `????````  XxdHMH~` >(iJO!_(> ```_ K        ,`
                .      .F` ` ``.c1s..HdMMH~````````````(BXVY=``.O>`.c_(>_````(-W
                      `J{;``` ``(+> `-77"= ```.````````````   ````..+>~~_````.}d
                       H(:```````.3 ..````````.````````````` `.` .>~~~({__ ``.Pd
                     ` Dd_```.....I ``````````_````````````````.v~~:~:(P_~_ ((bK
                       WM{ ...~~~~(o.``````````````` ..````` .?`(<:~(-+#_~~_1dH%
                       dvr-l..~~_s_w7+.``.<(-. ?!``~~..-<1.?!` J<+~:(iWH~::(kWF
                         X_w~~~(jM:Wc_O?42``` ?&+-;+<~``.(:` .4~(D~(Id!H~_(V!!
                         .hdm_~(d?hdNz-_(>``.._(_.(>_..``(:`` (1H%(uV! HV"!
                           7:?4uD.K~.._?z>`.._(JSjk-__`.`(C<<!_7H#"!
                                .dI:__-.I?&Jv=_+?>?l_?4v?> -< ...?h.
                    `        .JHz?1<:::J<(l ` J?1J<1_ `(:..?_...._Jb
                        `..v"!``(>(1+:(>~~(1.<(1<iJ><..C<_--1(:::+CJN.
                        J=````.` (a+g0Ws:::_:_::(<___<(~___(C~:<z<1>-Ta,`
                       `?e````.z@!     X<:::::::<+:::::?1+jdYTYAaZ!``` ?4a.`    `
                         (n.````Oe    .D_~~~:::::::::::::(W!     ?U, ````.To.      `
                          .4,````?Hka.f_....__~~::~:~:~~~_d;       (W,`` `` 7a.
                            ?N,  `-_4D..............~.~..._W,        ?NJ. ` ` ?4dYBh, `
                             JD?-   +_......................W.         _TS&,   `  ` TmJN`
                             .UR-...<z+-_-............-__-((dL             _Wn. `  .! (t   `
                            ` J8!_.2____<?<<<+(-(--(+<<1<<(_<jL             .N..`.J!  ?W&
                              d&J?` ~?<+-_(-~(-:(_: <.<(-(<7!_?o             ?B9Tn.` (4kdb
                        ` `.dY!   ` `./` ` _(????!!~!` ``(_``..?L                .4,m,iW.
                            .U,    `.!   `  !  `` `. `` ` < `...?r                 Wd?BY`
                              (N&.`.!` `   <  ```` _ ` ```(_`..(JV`   `  `
                             `(8-.?=<?1+-..+... ```(.......f<~?r          ` ` ......
                             .K`.?<-.   __(K<D__<?TC~~~~__```.-S.  ....-&ZY""777?77""9GJ,`   `
                            `J}````` _??<d= J{~~~~~(i.....-<<~`(Y77<~_``.```.```````.`.(XHa.    `
                        `   .K`````````.d^  X~~.~.~~_1. ````.`` I_....```.````.``.`````_dWqHm,
                           `(%``.`.```.Y    R~~~.~.~~~<-`````.``(-~~.....`.`````.``.``.(dWqkHh
                           .K_```.``.J^     S_~~~~~.~~~?:``.``.`.l~~~~...``.`.``````.``_zWkqkHb`
                        ` .d'`..```.Y`      q{~.~.~~.~.~(i ````.`(/.~~.....```.``.```.`.dWqqqqH[
                         .d!`~~_-.J^        .b_~.~~.~~~~~_1.  ..``?+~~~~....````````.` (WkHHM#H#
                         d!` __?(f`          ?n~~~.~~.~~~~~?i_.````?/~~.~..`.``.``.``._jkY"7=
                     `  .D``` `.%             ?h,~~~~.~..~~~~1, ``` j_~~....``.``.``.-V=`
                       `(}`   (\                Tm,~~~~~.~.~~~?- `` .>~~....``.``..JY`
               `   `   .g`   ('                   ?W&-~~~~~.~.~(>  ` 1_~~....`..JT^
                      d=<  .,Nx                      THaJ-_~~~~~(l   (o.(((JZ"^`
                `    .@   `?`.H.                        _"YBHmggk<!`` > W>
                      4eJ>:1.(t                                 W+.<(. .(D           `
                      ({?<!~db                                   W$<<jY4F`
                      ,h. _`.W`                                 (5..J=.d`
                    `   7TUY"`                                  4,...(Y!
                                                                  ~~`                         `

	でかいですね。
	更にかわいいときた。
	うん。好き。
*/
/*  include  */
#include <bits/stdc++.h>
using namespace std;
int main()
{
	static long long m1,m2;
	int N;
	cin>>N;
  vector<long long> v(N);
	for(int i=0;i<N;i++) cin>>v[i];
	sort(v.begin(),v.end(),greater<int>());
	for(int i=0;i<N;i++){
		if(v[i]==v[i+1]&&m1==0){m1=v[i],i++;}
		else if(v[i]==v[i+1]&&m2==0){m2=v[i],i++;}
		else if(m1&&m2) i=N;
	}
	cout<<m1*m2<<endl;
}

Measured memory_bytes: 1024