The following question arose when I thought about this question:
Art hobbyist seeking maximally dispersed Latin Square of order 7
A latin square of size $n$ is a $n\times n$ matrix containing $n$ distinct elements, where each element appears in exactly one row and exactly one column.
Let $L$ be a latin square and $f(L)$ the sum of all squared distances of all equal elements, formally:
with $L=(x_{ij})_{i,j=1\dots n}$, let
$$f(L)=\sum_{\{x_{ij}=x_{kl}, i where $d((a,b),(c,d))=\sqrt{(a-c)^2+(b-d)^2}$. Prove that $f(L)=(n^5-n^3)/6$ for any latin square $L$ of size $n$ (or give a counterexample). Example: The squared distances between the ones sum up to $(1^2+1^2)+(3^2+2^2)+(2^2+3^2)+(2^2+1^2)+(1^2+2^2)+(1^2+1^2) = 40\text.$
Likewise for the twos, threes and fours, yielding a total of 160 (=$(4^5-4^3)/6$). It feels pretty "clear" that the assertion holds for all $n$, but I'm having trouble writing down a formal proof.
1 2 3 4
4 1 2 3
2 3 4 1
3 4 1 2