Simple Python dynamic programming solution
\nMOD = 1000000007\nclass Solution:\n    def numFactoredBinaryTrees(self, arr: List[int]) -> int:\n        # smaller numbers multiply to form a larger number\n 
```\nMOD = 1000000007\nclass Solution:\n    def numFactoredBinaryTrees(self, arr: List[int]) -> int:\n        # smaller numbers multiply to form a larger number\n        # after sorting we only have to worry about numbers\n        # to the left of the current number\n        arr.sort()\n        # let dp[x] be the number of possible binary trees we\n        # can form using x as the root\n        dp = {x: 1 for x in arr}\n        # iterate through each number, using it as the root\n        for i in range(len(arr)):\n            # iterate through all numbers smaller than the current\n            # number\n            for j in range(i):\n                # check if big/small is in array, if yes, there\'d be\n                # dp[small]*dp[big/small] possible trees with big as\n                # root\n                if arr[i]/arr[j] in dp:\n                    dp[arr[i]] += dp[arr[j]]*dp[arr[i]/arr[j]]\n        \n        return sum(dp[x] for x in dp) % MOD\n```
['Dynamic Programming', 'Python', 'Python3']