c++ solution O(nlogn)
\nclass Solution {\npublic:\n    int waysToSplit(vector<int>& nums) {\n         int mod=1000000007;\n         int n=nums.size();\n         int ans=0;\n         
```\nclass Solution {\npublic:\n    int waysToSplit(vector<int>& nums) {\n         int mod=1000000007;\n         int n=nums.size();\n         int ans=0;\n         vector<int> prf(n);\n         int s=0;\n         for(int i=0; i<n; i++) {\n              s+=nums[i];\n              prf[i]=s;\n         }\n         for(int i=0; i<n; i++) {\n              int left=prf[i];\n              int mid=(prf.back()-prf[i])/2;\n              int leftwall=lower_bound(prf.begin()+i+1,prf.end(),left*2)-prf.begin(); // left most max value of mid subarr can go to 2*left \n              int rightwall=upper_bound(prf.begin()+i+1,prf.begin()+n-1,left+mid)-prf.begin(); // right most max value of third subarr can go to left+mid\n              rightwall--;\n              ans+=max(0,rightwall-leftwall+1);\n              ans%=mod;\n         } \n         return ans;\n    }\n};\n```
['Binary Search', 'C']