Generally-
a(0) + a(1)g(1) + a(2)g(1)g(2) + a(3)g(1)g(2)g(3) +......+a(m)g(1)...g(m) = Z/g(1)g(2)...g(m)g(m+1)Z (It's residue class)
Check this by maximising your a's to their full extent, you should get the supremum of the residue class you are looking for (this is due to the way in which the a's are bounded).
If we start from the beginning, a(0) goes up to g(1)-1 . If a(1) was unbounded, you could express every natural number just using the first two terms. As it is, the sum of the first two terms are bounded above by g(1)g(2), but you can hit g(1)g(2) whole residue class up to that point. So this argument keeps going and going until we get some unbounded a(m) ( a(k) for example

)