3. In the sequence $\left\{a_{n}\right\}$, for $1 \leqslant n \leqslant 5$, we have $a_{n}=n^{2}$; and for all positive integers $n$, we have $a_{n+5}+a_{n+1}=a_{n+4}+a_{n}$. Then $a_{2023}=$ $\qquad$ .
$$
\left\{\begin{array}{l}
a_{n+5}=a_{n+4}-a_{n+1}+a_{n}, \\
a_{n+6}=a_{n+5}-a_{n+2}+a_{n+1}, \\
a_{n+7}=a_{n+6}-a_{n+3}+a_{n+2}, \\
a_{n+8}=a_{n+7}-a_{n+4}+a_{n+3}
\end{array} \Rightarrow a_{n+8}=a_{n},\right.
$$

Thus $a_{2023}=a_{7}=a_{5}+a_{1}-a_{3}=25+1-9=17$.