public static int maxSubArray(ArrayList<Integer> nums) {
        // write your code
        int rel=Integer.MIN_VALUE/2,lm=Integer.MIN_VALUE/2;
        for (int a:nums) {
            lm=Math.max(a, lm+a);
            rel=Math.max(rel,lm);
        }
        return rel;
    }