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} \text {. }
$$

Then $a_{2023}=$ . $\qquad$
3. 17 .

For all positive integers $n$, we have
$$
a_{n+5}+a_{n+1}=a_{n+4}+a_{n}=\cdots=a_{5}+a_{1}=26 \text {. }
$$

Then $a_{n}=26-a_{n+4}=26-\left(26-a_{n+8}\right)=a_{n+8}$, which means $\left\{a_{n}\right\}$ is a sequence with a period of 8.
Therefore, $a_{2023}=a_{7}=26-a_{3}=26-9=17$.