#include #include using namespace std; int V[500004]; int main() { // #ifndef ONLINE_JUDGE // freopen("input.txt","r",stdin); // #endif // ONLINE_JUDGE int N; scanf("%d\n", &N); for(int i = 1; i <= N; ++i) { scanf("%d", &V[i]); } int ans = 0; for(int i = 1; i <= N; ++i) { int S = V[i]; int beauty = 0; for(int j = i + 1; j <= N; ++j) { beauty += S * V[j]; S += V[j]; ans = max(ans, beauty); } } cout << ans << '\n'; return 0; }