Accepted C# Solution with Binary Search
Idea:\n1)Calculate prefix sums\n2) Foreach possible border \'i\' of left subarray we can find lowest (\'left\') and highest (\'right\') possible index of middle
Idea:\n1)Calculate prefix sums\n2) Foreach possible border \'i\' of left subarray we can find lowest (\'left\') and highest (\'right\') possible index of middle subarray border.\n3) Answer = sum of (right - left + 1) for all i\n\n```\n public class Solution\n    {\n        private const int MODULO = 1000000007;\n\n        public int WaysToSplit(int[] nums)\n        {\n            checked\n            {\n                long[] sums = new long[nums.Length];\n                sums[0] = nums[0];\n                for (int i = 1; i < nums.Length; i++)\n                {\n                    sums[i] = sums[i - 1] + nums[i];\n                }\n\n                int res = 0;\n\n                for (int i = 0; i < nums.Length; i++)\n                {\n                    int l = i + 1;\n                    //-2 because third subarray should be also non-empty\n                    int r = nums.Length - 2;\n\n                    if (l > r)\n                    {\n                        continue;\n                    }\n\n                    int left = -1;\n                    int right = -1;\n\n                    while (r - l > 1)\n                    {\n                        int mid = l + (r - l) / 2;\n                        if (sums[mid] - sums[i] < sums[i])\n                        {\n                            l = mid;\n                        }\n                        else\n                        {\n                            r = mid;\n                        }\n                    }\n\n\n                    if (sums[l] - sums[i] >= sums[i])\n                    {\n                        left = l;\n                    }\n                    else\n                    {\n                        if (sums[r] - sums[i] >= sums[i])\n                        {\n                            left = r;\n                        }\n                    }\n\n\n                    l = i + 1;\n                    r = nums.Length - 2;\n\n                    long second = 0;\n                    long third = 0;\n\n                    while (r - l > 1)\n                    {\n                        int mid = l + (r - l) / 2;\n                        second = sums[mid] - sums[i];\n                        third = sums[nums.Length - 1] - sums[mid];\n\n                        if (second <= third)\n                        {\n                            l = mid;\n                        }\n                        else\n                        {\n                            r = mid;\n                        }\n                    }\n\n                    second = sums[r] - sums[i];\n                    third = sums[nums.Length - 1] - sums[r];\n\n                    if (second <= third)\n                    {\n                        right = r;\n                    }\n                    else\n                    {\n                        second = sums[l] - sums[i];\n                        third = sums[nums.Length - 1] - sums[l];\n\n                        if (second <= third)\n                        {\n                            right = l;\n                        }\n                    }\n\n\n                    if (right >= 0 && left >= 0)\n                    {\n                        res += Math.Max(0, right - left + 1);\n                        res %= MODULO;\n                    }\n                }\n\n                return res;\n            }\n        }\n    }\n\n```
['Binary Search']