Kadane's algorithm

in kadanes algo if i give all input as negetive(e.g. -1,-1 ,-1,-1)
then ans is wrong so what i do for this

Yeah in that case , you need to initialise the ans as the maximum element of the array.
If your max element is negative, you don’t need to run kadane’s algo , just print the maximum element,