A sequence of positive integers with a_1=1 and a_9+a_10=646 is formed so that the first three terms are in geometric progression, the second, third, and fourth terms are in arithmetic progression, and, in general, for all n>=1, the terms a_(2n-1), a_(2n), a_(2n+1) are in geometric progression, and the terms a_(2n), a_(2n+1), and a_(2n+2) are in arithmetic progression. Let a_n be the greatest term I this sequence that is less than 1000. Find a_n.