Hongjun has N pieces of matter laid out in a row. The amount of each piece is a positive integer.
Hongjun picks one contiguous run of pieces, then turns some of the picked pieces into antimatter and casts a spell. The spell succeeds when the total amount still left as matter equals the total amount turned into antimatter. Hongjun cannot cast a spell without picking anything, so he must pick at least 2 contiguous pieces.
Two cases count as different when the chosen run differs, or when the set of pieces turned into antimatter differs. Given the amounts, count the cases in which the spell succeeds.