public int maxTwoSubArrays_lint(ArrayList<Integer> nums) {
        // write your code
        int n = nums.size();
        int[] left = new int[n];
        int[] right = new int[n];
        int sum = 0, minSum = 0, max = Integer.MIN_VALUE;
        for (int i = 0; i < n; ++i) {
            int val = nums.get(i);
            sum += val;
            max = Math.max(max, sum - minSum);
            minSum = Math.min(minSum, sum);
            left[i] = max;
        }
        max = Integer.MIN_VALUE;
        minSum = 0;
        sum = 0;
        for (int i = n - 1; i >= 0; --i) {
            sum += nums.get(i);
            max = Math.max(max, sum - minSum);
            minSum = Math.min(minSum, sum);
            right[i] = max;
        }
        int ans = Integer.MIN_VALUE;
        for (int i = 0; i < n - 1; ++i) {
            ans = Math.max(ans, left[i] + right[i + 1]);
        }
        return ans;
    }