intSolution::solve(int A, vector<int> &B){ longlong sum = 0; for(auto b : B) sum += b; if(sum % 3) return0; longlong t = sum / 3; longlong now = 0; int res = 0, dp = 0; for(int i = 0; i < A - 1; i++) { now += B[i]; if(now == t * 2) res += dp; if(now == t) dp += 1; } return res; }