2023 SSMO Relay Round 5 Problems/Problem 1

Problem

Let $S_n$ be the set of all rational numbers of the form $0.\overline{a_1a_2a_3\dots a_n},$ where $n$ is an integer satisfying $n\geq 1$ and $a_1,a_2,\dots,a_n$ are nonzero integers. If \[n = 5\left(\sum_{n=1}^{\infty}\left(\sum_{a\in S_n}\frac{a}{10^{n}}\right)\right),\] find $n.$

Solution