#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int find_max_vapor_rate(vector<int>& vapor_rates) {
int n = vapor_rates.size();
if (n % 2 != 0) {
return 0; // If the number of chemicals is odd, there's no way to pair them up.
}
// Divide the chemicals into two sets and reverse the order of one set
vector<int> set1(vapor_rates.begin(), vapor_rates.begin() + n / 2);
vector<int> set2(vapor_rates.begin() + n / 2, vapor_rates.end());
reverse(set2.begin(), set2.end());
// Calculate the vapor rates for all possible pairings
vector<int> vapor_products(n / 2);
for (int i = 0; i < n / 2; ++i) {
vapor_products[i] = set1[i] * set2[i];
}
// Find the maximum vapor rate
int max_vapor_rate = *max_element(vapor_products.begin(), vapor_products.end());
return max_vapor_rate >= 0 ? max_vapor_rate : 0;
}
int main() {
int num_chemicals;
cin >> num_chemicals;
vector<int> vapor_rates(num_chemicals);
for (int i = 0; i < num_chemicals; ++i) {
cin >> vapor_rates[i];
}
int max_vapor_rate = find_max_vapor_rate(vapor_rates);
cout << max_vapor_rate << endl;
return 0;
}
CiNpbmNsdWRlIDxpb3N0cmVhbT4KI2luY2x1ZGUgPHZlY3Rvcj4KI2luY2x1ZGUgPGFsZ29yaXRobT4KCnVzaW5nIG5hbWVzcGFjZSBzdGQ7CgppbnQgZmluZF9tYXhfdmFwb3JfcmF0ZSh2ZWN0b3I8aW50PiYgdmFwb3JfcmF0ZXMpIHsKICAgIGludCBuID0gdmFwb3JfcmF0ZXMuc2l6ZSgpOwogICAgaWYgKG4gJSAyICE9IDApIHsKICAgICAgICByZXR1cm4gMDsgIC8vIElmIHRoZSBudW1iZXIgb2YgY2hlbWljYWxzIGlzIG9kZCwgdGhlcmUncyBubyB3YXkgdG8gcGFpciB0aGVtIHVwLgogICAgfQoKICAgIC8vIERpdmlkZSB0aGUgY2hlbWljYWxzIGludG8gdHdvIHNldHMgYW5kIHJldmVyc2UgdGhlIG9yZGVyIG9mIG9uZSBzZXQKICAgIHZlY3RvcjxpbnQ+IHNldDEodmFwb3JfcmF0ZXMuYmVnaW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