8. Arrange the $n$ consecutive positive integers from 1 to $n$ ($n>1$) in a sequence such that the sum of every two adjacent terms is a perfect square. The minimum value of $n$ is $\qquad$ .
8. 15 .

For example, a sequence arranged is
$$
8,1,15,10,6,3,13,12,4,5,11,14,2,7,9 \text {. }
$$

Let this set of $n$ consecutive positive integers be
$$
M=\{1,2, \cdots, n\} \text {. }
$$

Since $n>1$, the set $M$ must contain 2, and $2+7=9$, thus, $n \geqslant 7$.

When $n=7$, the numbers from 1 to 7 can be paired into three segments that meet the conditions:
$$
(1,3,6),(2,7),(4,5),
$$

but they cannot be connected into a 7-term sequence, so more numbers need to be added, i.e., $n \geqslant 10$.
Adding 8 can expand the first segment to $(8,1,3,6)$, and adding 9 can expand the second segment to $(2,7,9)$, but the new three segments still cannot be connected, and more numbers need to be added, i.e., $n \geqslant 10$.
If the previous numbers are adjacent to $8,9,10$, only
$$
8+1=9,9+7=16,10+6=16 \text {, }
$$

these segments can be expanded to
$$
(8,1,3,6,10),(2,7,9),(4,5),
$$

but they still cannot be connected. To achieve this, we need to use the new square number 25. The smallest number from 1 to 10 that can pair to sum up to 25 is 15, thus, $n \geqslant 15$.
When $M=\{1,2, \cdots, 15\}$, the sequence can be arranged as $8,1,15,10,6,3,13,12,4,5,11,14,2,7,9$.