579. Maximum Product Subarray

0

Medium

Given an array of integers, find a contiguous subarray that has the largest product, and return the product as the output. The test cases are designed in such a way that the answer will always fit in a 32-bit integer.

Input Format

The first line of the input contains the size of the array. The second line contains the elements of the array separated by spaces.

Output Format

Print the maximum product of a subarray.

Example

Input

4 2 3 -2 4

Output

6

Constraints

1 <= arr.length <= 2 * 104
-10 <= arr[i] <= 10
The product of any prefix or suffix of arr is guaranteed to fit in a 32-bit integer.
Loading...

View Submissions

Console