///F - Make a Rectangle
#include"bits/stdc++.h"

using namespace std;

int main(){

    vector<int> a;
    map<int,int> m;

    int N;
    scanf("%d",&N);

    for(int i = 0; i < N; i++){

        int k;
        scanf("%d",&k);
        a.push_back(k);

    }

    sort(a.rbegin(),a.rend());

    int max1 = 0,max2 = 0,maxsqr = 0;

    for(int i = 0; i < N; i++){

        int x;
        x = a[i];
        map<int,int>::iterator itr = m.find(x);

        if(!itr->second)
            m[x] = 1;
        else
            m[x]++;

        if(m[x] < 4)
        {

            if(m[x] > 1)
                max1 = max(max1,x);

            if(m[x] > 1 && x < max1)
                max2 = max(max2,x);

        }else
            maxsqr = max(maxsqr,x);

    }

    if(maxsqr*maxsqr > max1*max2)
        printf("%d",maxsqr*maxsqr);
    else
        printf("%ld",max1*max2);

    return 0;

}