rabbitmilk

Problem Description

White Rabbit is making milk! Black Rabbit is excited to try the new White Rabbit Milk launched at 7-11 stalls today.

There are N stalls. Black Rabbit wants to choose a contiguous section (of at least size 1) of stores to buy Rabbit Milk, and the satisfaction he gains is the product of quality across all the stores. However, White Rabbit's Milk has inconsistent quality, and may even be zero or negative. Store i has quality Ai. What is the maximum satisfaction he can gain?

It is guaranteed that for any contiguous section of stalls, the absolute value of the product of their quality doesn't exceed 1017.

Input

The first line of input will contain two integers, N.

The next line contains N integers, describing the quality of Rabbit Milk, Ai, of each store.

Output

The output should contain one integer, the maximum number of satisfaction Black Rabbit can gain.

Limits

For all subtasks: 1 ≤ N ≤ 1 000 000. -3 ≤ Ai ≤ 3

Subtask 1 (12%): N ≤ 400.

Subtask 2 (36%): N ≤ 4000.

Subtask 3 (8%): Ai ≥ 0.

Subtask 4 (24%): Ai ≠ 0.

Subtask 5 (20%): No additional constraints.

Subtask 6 (0%): Sample.

Sample Input

7
-1 2 -3 1 -2 0 3

Sample Output

12

Explanation

If he takes the 2nd to 5th stalls, he gets a total of 12 satisfaction.



Submitting .cpp to 'rabbitmilk'


You're not logged in! Click here to login

Time Limit: 1 Seconds
Memory Limit: 1024MB
Your best score: 0
Source: Dunjudge Archive

Subtask Score
1 12
2 36
3 8
4 24
5 20
6 0