4. Let the sequence $\left\{a_{n}\right\}$ satisfy $a_{1}=0, a_{2}=1$, and for all $n \geqslant 3, a_{n}$ is the smallest positive integer greater than $a_{n-1}$ such that there is no subsequence of $a_{1}, a_{2}, \cdots, a_{n}$ that forms an arithmetic sequence. Find $a_{2014}$.
4. First, prove a lemma using mathematical induction.

Lemma A non-negative integer appears in the sequence if and only if its ternary expansion contains only 0 and 1.
Proof It is obvious that the proposition holds for 0.
Assume the proposition holds for all non-negative integers less than \( N \), and consider \( N \).

If the ternary expansion of \( N \) contains the digit 2, replace all occurrences of 2 with 0 to get the number \( N_{0} \); replace all occurrences of 2 with 1 to get the number \( N_{1} \). Thus, the ternary expansions of \( N_{0} \) and \( N_{1} \) do not contain the digit 2.
By the induction hypothesis, the numbers \( N_{0} \) and \( N_{1} \) are in the sequence.
Since \( N_{0} \), \( N_{1} \), and \( N \) form an arithmetic sequence, \( N \) does not appear in the sequence. If the ternary expansion of \( N \) does not contain the digit 2, then we need to prove that \( N \) must appear in the sequence. If not, then there exist terms \( N_{0} \) and \( N_{1} \) in the sequence such that \( N_{0} \), \( N_{1} \), and \( N \) form an arithmetic sequence. Let the common difference be \( d \), and \( 3^{k} \| d \). Then the ternary expansions of these three numbers have the same lowest \( k-1 \) digits, and the \( k \)-th digit is different for each pair, so one of the numbers must have a 2 in the \( k \)-th digit, which contradicts the assumption.
Returning to the original problem.
We only need to find the 2014th non-negative integer whose ternary expansion does not contain the digit 2.

Notice that under this restriction, the ternary carry-over method is equivalent to binary, so we just need to write 2013 (note \( a_{1}=0 \)) in binary \((11111011101)_{2}\) and then convert it to ternary \( a_{2014}=88327 \).