You are given an array $$$a$$$ consisting of $$$n$$$ integers: $$$a_1, a_2, \ldots, a_n$$$. Your task is to count the number of ways to partition this array into exactly three contiguous subarrays such that the sum of elements in each subarray is equal.
More formally, you need to find the number of pairs of indices $$$(i, j)$$$ where $$$2 \leq i \leq j \leq n-1$$$, such that: $$$$$$\sum_{k=1}^{i-1} a_k = \sum_{k=i}^{j} a_k = \sum_{k=j+1}^{n} a_k$$$$$$
In other words, the array is split into three parts:
All three parts must have the same sum.
NOTE: Since the answer can be very large, output the result modulo $$$10^9 + 7$$$.
Input:
5 3 -3 0 3 -3
Output:
1
Input:
4 1 1 1 1
Output:
0