Maximum Absolute Sum Of Any Subarray

medium
You are given an integer array nums. The absolute sum of a subarray [numsl, numsl+1, ..., numsr-1, numsr] is abs(numsl + numsl+1 + ... + numsr-1 + numsr).

Return the maximum absolute sum of any (possibly empty) subarray of nums.

Note that abs(x) is defined as follows:

If x is a negative integer, then abs(x) = -x.
If x is a non-negative integer, then abs(x) = x.

Input Format

Input and output are managed for you. Just complete the function.

Output Format

Input and output are managed for you. Just complete the function.

Constraints

1 <= nums.length <= 10^5
-10^4 <= nums[i] <= 10^4

Notice

NA

Example

Input
5
1 -3 2 3 -4
Output
5
Previous
Check If Binary String Has At Most One Segment Of Ones
Next
Minimize Maximum Pair Sum In Array

Related Questions