← Home
Looking at this problem, I need to find which candies are "good" - when removed, the sum of weights eaten on odd days equals the sum on even days.

Key insight: When candy i is removed:
- Candies before i (positions 1 to i-1) keep their positions in the eating sequence
- Candies after i (positions i+1 to n) shift by 1 position, flipping their odd/even day assignment

So for removing candy i:
- **Odd day sum** = sum of odd-indexed candies before i + sum of even-indexed candies after i
- **Even day sum** = sum of even-indexed candies before i + sum of odd-indexed candies after i

Using prefix sums where `oddSum[k]` = sum of odd-indexed candies from 1 to k:
- Odd sum = `oddSum[i-1] + (totalEven - evenSum[i])`
- Even sum = `evenSum[i-1] + (totalOdd - oddSum[i])`

Setting these equal and simplifying:
- For **i odd**: `2 * diff[i-1] == D - a[i]`
- For **i even**: `2 * diff[i-1] == D + a[i]`

Where `D = totalOdd - totalEven` and `diff[k] = oddSum[k] - evenSum[k]`

Verification with example [1,4,3,3]:
- D = (1+3) - (4+3) = -3
- i=1: 2*0 = 0, D-a[1]=-4, not equal ❌
- i=2: 2*1 = 2, D+a[2]=1, not equal ❌  
- i=3: 2*(-3)=-6, D-a[3]=-6, equal ✓
- i=4: 2*0=0, D+a[4]=0, equal ✓

Result: 2 good candies ✓

```go
package main

import "fmt"

func main() {
    var n int
    fmt.Scan(&n)
    
    a := make([]int, n)
    for i := 0; i < n; i++ {
        fmt.Scan(&a[i])
    }
    
    oddSum := 0
    evenSum := 0
    
    for i := 0; i < n; i++ {
        if i%2 == 0 {
            oddSum += a[i]
        } else {
            evenSum += a[i]
        }
    }
    
    D := oddSum - evenSum
    
    oddSum = 0
    evenSum = 0
    
    count := 0
    for i := 0; i < n; i++ {
        diff := oddSum - evenSum
        
        var rhs int
        if i%2 == 0 {
            rhs = D - a[i]
        } else {
            rhs = D + a[i]
        }
        
        if 2*diff == rhs {
            count++
        }
        
        if i%2 == 0 {
            oddSum += a[i]
        } else {
            evenSum += a[i]
        }
    }
    
    fmt.Println(count)
}
```