Define the sequence $a_1, a_2,...$ as follows: $a_1 = 1$, and for every $n \ge 2$, $a_n = n - 2$ if $a_{n-1} = 0$ and $a_n = a_{n-1} - 1$, otherwise. Find the number of $1 \le k \le 2016$ such that there are non-negative integers $r, s$ and a positive integer $n$ satisfying $k = r + s$ and $a_{n+r} = a_n + s$.
Problem
Source: 2016 Saudi Arabia IMO TST , level 4, III p1
Tags: Sequence, algebra, recurrence relation