#include<bits/stdc++.h>
using namespace std;

int main(){
    int n;
    cin >> n;
    int a[n];

    int i;
    for(i=0;i<n;i++){
        cin >> a[i];
    }

    vector<int> dup;

    int j;
    for(i=0;i<n;i++){
        for(j=i+1;j<n;j++){
            if(a[i]==a[j]){

                dup.push_back(a[i]);
                a[i] = NULL;
                a[j] = NULL;
                break;
            }
        }
    }

    sort(dup.begin(), dup.end());

    int Size = dup.size();

    if(Size>=2){
        int r = dup[Size-2]*dup[Size-1];
        cout << r;
    }
    else{
        cout << 0;
    }
}