public static int maxSubArray(int[] A) {//solved after consulting
        int tempsum = 0;
        int max = 0x80000000;
        for (int i = 0; i < A.length; ++i) {
            tempsum += A[i];
            if (tempsum > max) max = tempsum;
            if (tempsum < 0) {
                tempsum = 0;
            }
        }
        return max;
    }