Simple C++ Solution
\nclass Solution {\npublic:\n    vector < vector < long long > > pascal;\n    int MOD = 1e9 + 7;\n    \n    int numOfWays(vector<int>& nums) {\n        int N = 
```\nclass Solution {\npublic:\n    vector < vector < long long > > pascal;\n    int MOD = 1e9 + 7;\n    \n    int numOfWays(vector<int>& nums) {\n        int N = nums.size();\n        pascal = vector < vector < long long > > (N + 1);\n        for (int i = 0; i < N + 1; i ++){\n            pascal[i] = vector < long long > (i + 1, 1);\n            for (int j = 1; j < i; j ++){\n                pascal[i][j] = (pascal[i - 1][j] + pascal[i - 1][j - 1])%MOD;\n            }\n        }\n        return dfs(nums) - 1;\n    }\n    \n    int dfs(vector < int > nums){\n        if (nums.size() <= 2)\n            return 1;\n        vector < int > left, right;\n        for (int i = 1; i < int(nums.size()); i ++){\n            if (nums[i] < nums[0])\n                left.push_back(nums[i]);\n            else\n                right.push_back(nums[i]);\n        }\n        return (((dfs(left) * pascal[nums.size() - 1][left.size()]) % MOD) * dfs(right))%MOD;\n    }\n};\n```
[]