Let p,q≥2 be coprime integers. A list of integers (r,a1,a2,...,an) with ∣ai∣≥2 for all i is said to be an expansion of p/q if
qp=r+a1+a2+...+an1111.
Now define the weight of an expansion (r,a1,a2,...,an) to be the product
(∣a1∣−1)(∣a2∣−1)...(∣an∣−1).
Show that the sum of the weights of all expansions of p/q is q.