combination + recursion
\nclass Solution {\npublic:\n    vector<vector<long long int >> comb;\n    int mod = 1e9+7;\n    \n    long long int solve(vector<int>& v)\n    {\n        int n
```\nclass Solution {\npublic:\n    vector<vector<long long int >> comb;\n    int mod = 1e9+7;\n    \n    long long int solve(vector<int>& v)\n    {\n        int n = v.size();\n        if(n<=2)\n            return 1;\n        \n        vector<int > l ,r;\n        for(int i=1;i<n;i++){\n            if(v[i]<v[0])\n                l.push_back(v[i]);\n            else\n                r.push_back(v[i]);\n        }\n        \n        \n        long long int lans = solve(l)%mod;\n        long long int rans = solve(r)%mod;\n        \n        int llen = l.size();\n        return ((((comb[n-1][llen] * lans ) %mod)*rans)%mod);\n    }\n    \n    int numOfWays(vector<int>& v) {\n        \n        int n = v.size();\n        comb.resize(n+1);\n        for(int i=0;i<n+1;i++)\n        {\n            comb[i] = vector<long long int>(i+1,1);\n            for(int j=1;j<i;j++)\n            {\n                comb[i][j] = (comb[i-1][j-1]+comb[i-1][j]) %mod;\n            }\n        }\n        \n        long long int ans = solve(v);\n        return ans%mod - 1;\n    }\n};\n```
['C']