Kadanes algo isnt running

there were couple of small mistakes in your code

  1. instead of adding a[k] you were adding a[i] to cumsum
  2. size of the array a was small

Corrected Code with comments: