For each integer a0>1a_0 > 1, define the sequence a0,a1,a2,a_0, a_1, a_2, \ldots by:

an+1={anif an is an integer,an+3otherwise,for each n0.a_{n+1} = \begin{cases} \sqrt{a_n} & \text{if } \sqrt{a_n} \text{ is an integer,} \\ a_n + 3 & \text{otherwise,} \end{cases} \quad \text{for each } n \geqslant 0.

Determine all values of a0a_0 for which there is a number AA such that an=Aa_n = A for infinitely many values of nn.