------
## 最终结论
```python
def numFactoredBinaryTrees(A):
    MOD = 10**9 + 7
    A.sort()
    dp = {}
    
    for num in A:
        dp[num] = 1  # Each number can be a tree by itself

    for root in A:
        for i in range(len(A)):
            if A[i] > root:
                break
            if root % A[i] == 0:  # Check if A[i] is a factor
                other_factor = root // A[i]
                if other_factor in dp:
                    dp[root] += dp[A[i]] * dp[other_factor]
                    dp[root] %= MOD

    return sum(dp.values()) % MOD

# Example usage:
A1 = [2, 4]
print(numFactoredBinaryTrees(A1))  # Output: 3

A2 = [2, 4, 5, 10]
print(numFactoredBinaryTrees(A2))  # Output: 7
```