#include <bits/stdc++.h>

using namespace std;

map<int,int> m;
int n;
int a, ans1, ans2, cnt;

int main() {
    scanf("%d", &n);
    for(int i = 0, t; i < n; i++) {
        scanf("%d", &t);
        m[t]++;
    }
    for(auto itr = m.rbegin(); itr != m.rend(); itr++) {
        //if (*itr ) {
            int a = itr -> second;
            if(a >= 4 && cnt == 0) {
                ans1 = itr -> first;
                ans2 = itr -> first;
                cnt += 2;
            }
        //}
            else if(a >= 2 && cnt != 2) {
                if(cnt == 1) ans2 = itr -> first;
                else if (cnt == 0) ans1 = itr -> first;
                cnt++;
            }
            if(cnt == 2) return (!printf("%lld", 1ll * ans1 * ans2));
    }
    printf("0");
}
