C++#include<bits/stdc++.h>
using namespace std;
int n;
long long a[500005];
int zero;
int one;
bool flag = false;
set<int>st;
int main() {
cin >> n;
for (int i = 1;i <= n;i++) {
cin >> a[i];
if (a[i] == 0)zero++;
if (a[i] == 1)one++;
if (a[i] >= 2)flag = true;
}
if (zero == 0) {
cout << "0" << endl;
return 0;
}
if (flag == false) {
if (one == 1) {
cout << "1" << endl;
}
else if (one == 0) {
cout << "0" << endl;
}
else cout << "2" << endl;
}
else {
sort(a + 1, a + 1 + n);
long long l = a[n];
a[n] = 0;
for (int i = 1;i <= n;i++) {
st.insert(a[i]);
}
long long r = 0;
auto it = st.find(r);
while (it != st.end()) {
r++;
it = st.find(r);
}
cout << r * l;
}
return 0;
}