// Original C++ solution (slower):
/*****************

 *   I<3   C++   *

 *  IWANT ANYAC  *

 * ILOVEPROGRAM! *

 *IT'SINTERESTING*

 * ILOVEPROGRAM! *

 *  INCONTESTS   *

 *   GETSCORE    *

 *    ACCODE     *

 *     LETS      *

 *      GO       *

 *Written by:    *

 *    charlieyan *

 *****************/

#include <assert.h>

#include <ctype.h>

#include <errno.h>

#include <float.h>

#include <fstream>

#include <iomanip>

#include <iostream>

#include <limits>

#include <locale>

#include <math.h>

#include <stdio.h>

#include <stdlib.h>

#include <string.h>

#include <time.h>

#include <wchar.h>

#include <wctype.h>

#include <algorithm>

#include <bitset>

#include <cctype>

#include <cerrno>

#include <clocale>

#include <cmath>

#include <complex>

#include <cstdio>

#include <cstdlib>

#include <cstring>

#include <ctime>

#include <deque>

#include <exception>

#include <fstream>

#include <functional>

#include <limits>

#include <map>

#include <iomanip>

#include <ios>

#include <iosfwd>

#include <istream>

#include <ostream>

#include <queue>

#include <set>

#include <sstream>

#include <stack>

#include <stdexcept>

#include <streambuf>

#include <string>

#include <utility>

#include <vector>

#include <cwchar>

#include <cwctype>

#include <complex.h>

#include <fenv.h>

#include <inttypes.h>

#include <stdbool.h>

#include <stdint.h>

#include <tgmath.h>

#include <numeric>

#include <list>

#define LL long long

#define pb push_back

#define pob pop_back

#define mp make_pair

#define FILL(a,v) memset((void*)a,v,sizeof(a))

#define FILL0(a) FILL(a,0)

#define FILL1(a) FILL(a,-1)

#define fillbig(a,m,v) fill((void*)a,(void*)a+m,v)

#define ALL(a) (a).begin(),(a).end()

#define Inf ((int)1e9+(int)1e8+(int)1e7)

#define INF ((long long)1e18+(long long)1e17+(long long)1e16)

#define Mod 1000000007

#define foreach(it,x) for(typeof(x.begin()) it=x.begin();it!=x.end();it++)

#define FOR(i,x) for(int i=0;i<x;i++)

#define RFOR(i,x) for(int i=x-1;i>=0;i--)

#define FFOR(i,a,b) for(int i=a;i<b;i++)

#define FRFOR(i,a,b) for(int i=a-1;i>=b;i--)

#define SZ(a) ((int)(a).size())

#define FI first

#define SE second

#define OVER(a) return puts(a),0

#define fastio ios::sync_with_stdio(0)

#define filei(f) freopen(f,"r",stdin)

#define fileo(f) freopen(f,"w",stdout)

#define eprintf(...) fprintf(stderr,__VA_ARGS__)

#define MASK(a) (1<<(a))

#define MASKX(x,a) ((x)<<(a))

#define BIT(a,b) ((a>>b)&1)

#define cddx(a) priority_queue<a >

#define cxdd(a) priority_queue<a,vector<a >,greater<a > >

using namespace std;

typedef pair<int,int> pii;

typedef unsigned long long UINT;

typedef unsigned int uint;

typedef long long INT;

typedef long double ldouble;

typedef pair<INT,INT> PII;

typedef stringstream sst;

typedef istringstream iss;

typedef vector<int> vint;

typedef vector<INT> VINT;

typedef vector<pii> vpii;

typedef vector<PII> VPII;

typedef priority_queue<int> pqi;

typedef priority_queue<INT> PQI;

typedef priority_queue<pii> pqp;

typedef priority_queue<PII> PQP;

typedef priority_queue<int,vint,greater<int> > xqi;

typedef priority_queue<INT,VINT,greater<INT> > XQI;

typedef priority_queue<pii,vpii,greater<pii> > xqp;

typedef priority_queue<PII,VPII,greater<PII> > XQP;



int n;

int a[100007];

int max1=0,max2=0;

int cnt,lst;



bool CONGDADAOXIAO(int a,int b){return a>b;}

int main()

{

	scanf("%d",&n);

	for(int i=0;i<n;i++)scanf("%d",a+i);

	sort(a,a+n,CONGDADAOXIAO);

	cnt=0;

	lst=-1;

	for(int i=0;i<=n;i++)

	{

		if(cnt==2)

		{

			if(!max1)max1=lst;

			else if(!max2)

				max2=lst;

			cnt=0;

		}

		if(a[i]!=lst)

		{

			lst=a[i];

			cnt=1;

		}

		else cnt++;

	}

	printf("%lld\n",1LL*max1*max2);

	return 0;

}

// Optimized solution to the same problem (faster):
#include<cstdio>

#include<cstring>

#include<algorithm>

#define ll long long

#define N 100005

#define mod 1000000007

#define rep(i,j,k) for (ll i=j;i<=k;++i)

#define per(i,j,k) for (ll i=j;i>=k;--i)

using namespace std;

inline ll read(){

	char ch=getchar(); ll x=0,f=1;

	while (ch<'0'||ch>'9') { if (ch=='-') f=-1; ch=getchar(); }

	while (ch>='0'&&ch<='9') { x=x*10+ch-'0'; ch=getchar(); }

	return x*f;

}

ll n,tot,ans1,ans2,a[N];

int main(){

	n=read();

	rep(i,1,n) a[i]=read();

	sort(a+1,a+1+n);

	for (ll l=1,r=1;l<=n;l=++r){

		while (a[l]==a[r+1]) ++r;

		if (r-l+1>=2) ans2=ans1,ans1=a[l];

		if (r-l+1>=4) ans2=ans1,ans1=a[l];

	}

	printf("%lld",ans1*ans2);

}

// Fastest known solution for this problem: