# Square Matrix

$A=\begin{pmatrix} 1 & 23 & \cdots & 5700 \\ 3 & 273 & \cdots & 7801 \\ \vdots & \vdots & \ddots & \vdots \\ 578 & 2061 & \cdots & 1000^2 \end{pmatrix}$

Imagine a large $$1000 \times 1000$$ matrix $$A$$ filled with the integers $$1$$ through $$1000^2$$, each appearing exactly once. The matrix above is one such example, with no particular ordering of the numbers.

Entries are said to be adjacent if one is directly above, below, left, or right of the other. (In other words, next to each other horizontally or vertically) Let the maximum difference between adjacent entries be $$D$$. What is the minimum possible value of $$D$$ over all matrices of this type?

×