Unable to catch the bug in DP problem

dynamic-programming
spoj

#1

I used an array named DP for storing the previously computed answers. First I copied the elements of the first row from array a to the first row of DP. And then I chose the maximum of the respective positions from the previous row of array DP and take a sum of it with the current element of array a and store this value at the respective position in array DP.
Although I passed too many test cases but still getting a wrong answer.
Please help me figuring out the bug.

Thanks in advance.
Link to the source code

Link to the problem