Albert has arranged the numbers from $1$ to $N$ in a line such that the sum of any two adjacent numbers is a perfect square. What is the greatest $N$ for which this is possible?