#include #include #include int main() { int n; std::cin >> n; long long min = 0; long long max = 0; for (int i = 0; i < n; i++) { int a; std::cin >> a; long long min0 = min; long long max0 = max; min = std::min({ min0 + a, min0 - a, min0 * a, max0 * a }); max = std::max({ max0 + a, max0 - a, min0 * a, max0 * a }); } std::cout << max << std::endl; }