There is an array of N integers, you are given a task to make any number of partitions in the array such that the Special Sum of all the partitions combined is maximized.
Suppose you make K partitions then the Special Sum is defined as P1 - P2 + P3 - P4 + P5 ..... +(-1)(K - 1)Pk.
Here Pi is defined as summation of all integers in that partition.
Input :
Output :
Constraint :
You can make three partitions , first from [0,0], second from [1,2] and third from [3,4].
Special value of such partions = 1 - (-2 + -3) + (2 + 1) = 9.