JS || Solution by Bharadwaj
Code\n\nvar waysToSplit = function (A) {\n    let N = A.length;\n    let mod = 1e9 + 7;\n    let pre = [...A];\n    for (let i = 1; i < N; i++) pre[i] += pre[i 
# Code\n```\nvar waysToSplit = function (A) {\n    let N = A.length;\n    let mod = 1e9 + 7;\n    let pre = [...A];\n    for (let i = 1; i < N; i++) pre[i] += pre[i - 1];\n    let res = 0;\n    for (let i = 0, j = 1, k = 1; i < N - 2; i++) {\n        j = Math.max(j, i + 1);\n        k = Math.max(k, j);\n        let left = pre[i];\n        if (left > pre[N - 1] / 3) break;\n\n        while (left > pre[j] - pre[i] && j < N - 1) j++;\n        if (j >= N - 1) break;\n\n        while (pre[k] - pre[i] <= pre[N - 1] - pre[k] && k < N - 1) k++;\n        k--;\n        if (k < j || k >= N - 1) continue;\n\n        res += (k - j + 1) % mod;\n    }\n    return res % mod;\n};\n```
['JavaScript']