Function to return maximum subarray sum of each connected component using Kadane 's Algorithm
static int subarraySum ( int [ ] arr , int n ) { int maxSubarraySum = arr [ 0 ] ; int currentMax = arr [ 0 ] ;