#include<bits/stdc++.h>
#define ull unsigned long long
#define ll long long
#define all(x) x.begin(), x.end()
using namespace std;
const int maxn = 1e5 + 1;
ll A[3001][3001];
map<pair<int, int>, int> mp;
int main() {
ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int n;
ll x;
cin >> n;
for (int i = 1; i <= n; ++i) {
cin >> x;
A[0][i] = x;
A[n - i + 1][0] = x;
}
for (int i = 1; i <= n; ++i) {
for (int j = 1; j <= n; ++j) {
A[i][j] = A[0][j] * A[i][0];
}
}
int j = n;
for (int i = 1; i <= n; ++i) {
mp[make_pair(i, j)] = true;
--j;
}
ll res = INT_MIN;
for (int i = 1; i < n; ++i) {
for (int j = 1; j < n; ++j) {
int fakeI = i, fakeJ = j;
ll sum = 0;
while (mp[make_pair(fakeI, fakeJ)] == false && fakeI < n && fakeJ < n) {
sum += A[fakeI][fakeJ];
++fakeI;
++fakeJ;
}
res = max(res, sum);
}
}
cout<<res;
}
I2luY2x1ZGU8Yml0cy9zdGRjKysuaD4KI2RlZmluZSB1bGwgdW5zaWduZWQgbG9uZyBsb25nCiNkZWZpbmUgbGwgbG9uZyBsb25nCiNkZWZpbmUgYWxsKHgpIHguYmVnaW4oKSwgeC5lbmQoKQp1c2luZyBuYW1lc3BhY2Ugc3RkOwpjb25zdCBpbnQgbWF4biA9IDFlNSArIDE7CmxsIEFbMzAwMV1bMzAwMV07Cm1hcDxwYWlyPGludCwgaW50PiwgaW50PiBtcDsKaW50IG1haW4oKSB7CiAgICBpb3NfYmFzZTo6c3luY193aXRoX3N0ZGlvKDApOyBjaW4udGllKDApOyBjb3V0LnRpZSgwKTsKICAgIGludCBuOwogICAgbGwgeDsKICAgIGNpbiA+PiBuOwogICAgZm9yIChpbnQgaSA9IDE7IGkgPD0gbjsgKytpKSB7CiAgICAgICAgY2luID4+IHg7CiAgICAgICAgQVswXVtpXSA9IHg7CiAgICAgICAgQVtuIC0gaSArIDFdWzBdID0geDsKICAgIH0KICAgIGZvciAoaW50IGkgPSAxOyBpIDw9IG47ICsraSkgewogICAgICAgIGZvciAoaW50IGogPSAxOyBqIDw9IG47ICsraikgewogICAgICAgICAgICBBW2ldW2pdID0gQVswXVtqXSAqIEFbaV1bMF07CiAgICAgICAgfQogICAgfQogICAgaW50IGogPSBuOwogICAgZm9yIChpbnQgaSA9IDE7IGkgPD0gbjsgKytpKSB7CiAgICAgICAgbXBbbWFrZV9wYWlyKGksIGopXSA9IHRydWU7CiAgICAgICAgLS1qOwogICAgfQogICAgbGwgcmVzID0gSU5UX01JTjsKICAgIGZvciAoaW50IGkgPSAxOyBpIDwgbjsgKytpKSB7CiAgICAgICAgZm9yIChpbnQgaiA9IDE7IGogPCBuOyArK2opIHsKICAgICAgICAgICAgaW50IGZha2VJID0gaSwgZmFrZUogPSBqOwogICAgICAgICAgICBsbCBzdW0gPSAwOwogICAgICAgICAgICB3aGlsZSAobXBbbWFrZV9wYWlyKGZha2VJLCBmYWtlSildID09IGZhbHNlICYmIGZha2VJIDwgbiAmJiBmYWtlSiA8IG4pIHsKICAgICAgICAgICAgICAgIHN1bSArPSBBW2Zha2VJXVtmYWtlSl07CiAgICAgICAgICAgICAgICArK2Zha2VJOwogICAgICAgICAgICAgICAgKytmYWtlSjsKICAgICAgICAgICAgfQogICAgICAgICAgICByZXMgPSBtYXgocmVzLCBzdW0pOwogICAgICAgIH0KICAgIH0KICAgIGNvdXQ8PHJlczsKfQo=