#include <iostream>
#include <algorithm>
#include <string>
#include <map>
using namespace std;

int main(){
	map<char, int> m;
	m['I'] = 1;m['V'] = 5;m['X'] = 10;m['L'] = 50;
	m['C'] = 100;m['D'] = 500;m['M'] = 1000;
	string s;
	while(cin >> s){
		int i = 0, ans = 0;
		while(i < s.size()){
			char c = s[i];
			int t = 0;
			for(i;c == s[i] && i < s.size()-1;i++)t += m[c];
			if(m[c] < m[s[i]])ans -= t;
			else ans += t;
			if(i == s.size()-1)ans += m[s[i++]];
		}
		cout << ans << endl;
	}
	return 0;
}
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<long long> vl;

int main() {
    int N;
    cin >> N;
    map<ll, ll> A;
    rep(i, N) {
        ll tmp;
        cin >> tmp;
        A[tmp]++;
    }

    vl st;
    for (auto x : A) {
        int y = x.second;
        while (y >= 2) {
            y -= 2;
            st.push_back(x.first);
        }
    }

    if (st.size() < 2) {
        cout << 0 << endl;
    } else {
        sort(st.begin(), st.end());
        reverse(st.begin(), st.end());

        ll ans = st[0] * st[1];

        cout << ans << endl;
    }
}