Consider the permutation of $1, 2, \dots, n$, which we denote as $\{a_1, a_2, \dots, a_n\}$. Let $f(n)$ be the number of these permutations satisfying the following conditions:
(1) $a_1 = 1$;
(2) $|a_i - a_{i-1}| \le 2, i = 1, 2, \dots, n-1$.
What is the residue when we divide $f(2015)$ by 4?