Consider the sequence \(a_1,a_2,a_3,a_4...\) such that \(a_1=2\) and for every positive integer \(n\), \(a_{n+1}=a_n+p_n\), where \(p_n\) is the largest prime factor of \(a_n\). The first few terms of the sequence are \(2,4,6,9,12,15,20\). What is the largest value of \(n\) such that \(a_n\) is a four-digit number?