【题解】Tanya and Candies
Tanya has nn candies numTanya and Candies bered from 11 to nn. The ii-th candy has the weight aiai.
She plans to eat exactly n−1n−1 candies and give the remaining candy to her dad. Tanya eats candies in order of increasing their numbers, exactly one candy per day.
Your task is to find the number of such candies ii (let's call these candies good) that if dad gets the ii-th candy then the sum of weights of candies Tanya eats in even days will be equal to the sum of weights of candies Tanya eats in odd days. Note that at first, she will give the candy, after it she will eat the remaining candies one by one.
For example, n=4n=4 and weights are [1,4,3,3][1,4,3,3]. Consider all possible cases to give a candy to dad:
- Tanya gives the 11-st candy to dad (a1=1a1=1), the remaining candies are [4,3,3][4,3,3]. She will eat a2=4a2=4 in the first day, a3=3a3=3 in the second day, a4=3a4=