Python3 Solution
\n\nclass Solution:\n    def numOfWays(self, nums: List[int]) -> int:\n        mod=10**9+7\n        \n        def f(nums):\n            n=len(nums)\n           
\n```\nclass Solution:\n    def numOfWays(self, nums: List[int]) -> int:\n        mod=10**9+7\n        \n        def f(nums):\n            n=len(nums)\n            if n<=1:\n                return len(nums) \n\n            left=[i for i in nums if i<nums[0]]\n            right=[i for i in nums if i>nums[0]]\n\n            Left=f(left)\n            Right=f(right)\n\n            if not Left or not Right :\n                return Left or Right\n            ans=comb(len(right)+len(left),len(right))\n            return ans*Left*Right\n\n        return (f(nums)-1)%mod    \n\n        return (f(nums)-1)%mod        \n```
['Python', 'Python3']