values. It is cut into three non-empty contiguous pieces: left, middle and right.
A cut is **good** if the sum of the left piece is at most the sum of the middle one, and the sum of the middle piece is at most the sum of the right one.
Return the number of good cuts. The answer can be large, so return it modulo 10⁹ + 7.values=[2, 2, 3, 1, 4] → 3
Good cuts are [2] [2] [3, 1, 4] (2 ≤ 2 ≤ 8), [2] [2, 3] [1, 4] (2 ≤ 5 ≤ 5) and [2, 2] [3, 1] [4] (4 ≤ 4 ≤ 4). For instance, [2] [2, 3, 1] [4] fails because 6 > 4. So the answer is 3.
values=[5, 4, 3] → 0
The only split is [5] [4] [3], but 5 > 4, so the answer is 0.
values=[0, 0, 0, 0] → 3
values=[2, 2, 3, 1, 4]
3
Run checks the first 3 tests in your browser. Submit checks all 89 tests on the server, hidden ones included.