TITLE: Mean distance between matrix entries
QUESTION [6 upvotes]: Given a $4$ by $4$ matrix, or in general an $n$ by $n$ square matrix, can we determine the mean euclidean distance (i.e. $\sqrt{\Delta x ^2 + \Delta y^2}$) between entries that are not neighbours? 
Two matrix entries $(x_1,y_1)$ and $(x_2,y_2)$ are neighbours if $\Delta x=\Delta y=1$ or $\Delta x=1$ and $\Delta y=0$; or lastly $\Delta x=0$ and $\Delta y=1.$ This means for example that the middle entry $(2,2)$ in a $3$ by $3$ matrix has $8$ neighbours, which means that this entry cannot be paired with any other matrix entry to create a non-neighbouring pair. This also means that all entries in a 2 by 2 matrix (below the entry coordinates in the matrix are written)
\begin{matrix}
  (1,1) & (1,2)  \\
  (2,1) & (2,2)  
 \end{matrix}
are considered as neighbours. 
I understand the first part to solve is: for a given matrix size, how many non-neighbouring pairs of entries are there? For example in a $3$ by $3$ matrix, we have $16$ combinations of entries that are not neighbours. Note we care about combinations of entries because for example the pair $(1,3) \& (3,3)$ and the pair $(3,3) \& (1,3)$ are considered as indistinguishable, i.e., swapping the position of an entry in a pair does not count as a new pair of entries.
Once we know the count $C$ of non-neighbouring pairs, then we can safely assign each pair with a probability $1/C,$ in order to solve the mean distance problem.

REPLY [3 votes]: Disclaimer: This approach is a work in progress, and it is not yet clear whether it leads to a nice solution. But perhaps it inspires someone else to a solution.

The mean distance between a pair of points, including neighbours, is
$$\frac12\cdot\frac{1}{\binom{n^2}{2}}\sum_{i,j,k,l}\sqrt{(i-j)^2+(k-l)^2}=\frac{1}{n^2(n^2-1)}\sum_{i,j,k,l}\sqrt{(i-j)^2+(k-l)^2},$$
where all indices run from $1$ to $n$. Here we count every pair twice, and hence divide the whole thing by $2$. The contribution from the pairs of neighbours is as follows: 
\begin{align*}
\text{corners}:&&4\times(2\times1+1\times\sqrt{2})
=&&8+4\sqrt{2},\\
\text{sides}:&&4(n-2)(3\times1+2\times\sqrt{2})
=&&4(3+2\sqrt{2})n-8(3+2\sqrt{2}),\\
\text{center}:&&(n-2)^2(4\times1+4\times\sqrt{2})
=&&4(1+\sqrt{2})n^2-16(1+\sqrt{2})n+16(1+\sqrt{2}).
\end{align*}
So the total number of pairs we overcounted is
$$4\times3+(n-2)\times5+(n-2)^2\times8=8n^2-54n+78,$$
and the sum of their distances is
$$4(1+\sqrt{2})n^2-4(1+2\sqrt{2})n+4\sqrt{2}.$$
Now it remains to determine the value of the sum
$$S(n):=\sum_{i,j,k,l}\sqrt{(i-j)^2+(k-l)^2},$$
where the indices all range from $1$ to $n$. This seems nice enough that someone might have written down some thoughts on it before...