------
## 最终结论
```python
def maxSumTwoNoOverlap(A, L, M):
    def maxSum(L, M):
        maxL = maxM = 0  # Initialize maximum sums for lengths L and M
        sumL = sumM = 0  # Initialize current sums for lengths L and M
        result = 0  # Initialize the result to keep track of the maximum sum found
        
        for i in range(len(A)):
            if i >= L:
                sumL += A[i] - A[i - L]  # Update sumL by adding current element and removing the element going out of the window
            else:
                sumL += A[i]  # Sum up elements until we reach length L
            
            if i >= L + M:
                sumM += A[i] - A[i - M]  # Update sumM similarly for the second subarray
                maxL = max(maxL, sumL)  # Update maxL with the maximum found so far
                result = max(result, maxL + sumM)  # Calculate potential result
                
            elif i >= M:
                sumM += A[i] - A[i - M]  # Continue to build sumM
            
            else:
                sumM += A[i]  # Sum up elements until we reach length M
            
            if i >= L + M - 1:
                result = max(result, sumL + maxM)  # Calculate potential result with the condition that both subarrays are valid

        return result

    return max(maxSum(L, M), maxSum(M, L))  # Compare results from both orders of subarrays

# Example usage
A1 = [0,6,5,2,2,5,1,9,4]
L1 = 1
M1 = 2
print(maxSumTwoNoOverlap(A1, L1, M1)) # Output: 20

A2 = [3,8,1,3,2,1,8,9,0]
L2 = 3
M2 = 2
print(maxSumTwoNoOverlap(A2, L2, M2)) # Output: 29

A3 = [2,1,5,6,0,9,5,0,3,8]
L3 = 4
M3 = 3
print(maxSumTwoNoOverlap(A3, L3, M3)) # Output: 31
```