AlgoUniversity
  • Go Back
Discussion
Positive Prefixes :

Author

Lokesh

Difficulty Level : Easy

Submissions : 180

Asked In :

Marks :10

: 0 | : 1

Prefix sum at position $$$i$$$ is defined as $$$prefix[i] = arr[0]+arr[1]+....arr[i]$$$

Rearrange the given array in such a way that no of the elements which are positive in the prefix sum array is maximum

Output the maximum number of positive elements possible in the prefix array after rearranging

Input

The first line contains $$$1 \le N \le 10^5$$$, denoting the number of elements in array $$$A$$$

The second line contains $$$N$$$ integers denoting elements of array $$$A$$$. $$$-10^9 \le A[i] \le 10^9 $$$

Output

Output a single integer denoting the maximum number of positive elements possible in rearranged $$$A$$$.

Examples

Input
4
-6 3 4 -10
Output
3
Input
4
-3 0 2 1
Output
3

You need to login to view your submissions.

You need to login to view all submissions.

Loading...

Result : Executed

Loading...

Feel something is wrong with the test cases?

Result : Accepted

Test Cases :

You need to Log In
We're glad that you want to attempt this problem!

But to Run or Submit the Problem, you need to Log In.

Continue to Log In
Challenge Submitted!

Your challenge has been submitted successfully.

You will get a response soon via WhatsApp or Email.

Challenge
Facing issue while trying to solve the problem! Don't worry, we got you covered!

Do let us know your issue.

Looks good!
Please enter your issue / feedback.

How do we get in touch with you?
Looks good!
Please enter your phone no.
Looks good!
Please enter your email address.