Problem: Legs $L_1$, $L_2$, $L_3$, $L_4$ of a square table each have length $n$,
where $n$ is a positive integer.
For how many ordered $4$-tuples $(k_1, k_2, k_3, k_4)$ of nonnegative integers
can we cut a piece of length $k_i$ from the end of leg $L_i$
and still have a stable table?

(The table is \emph{stable} if it can be placed
so that all four of the leg ends touch the floor.
Note that a cut leg of length $0$ is permitted.)

Solution: Flip the table upside-down so that that the table's surface
rests on the floor.
Then, we see that we want the truncated legs
to have endpoints $A$, $B$, $C$, $D$ which are coplanar (say).
\begin{claim*}
  This occurs if and only if $ABCD$ is a parallelogram.
\end{claim*}
\begin{proof}
  Obviously $ABCD$ being a parallelogram is sufficient.
  Conversely, if they are coplanar,
  we let $D'$ be such that $ABCD'$ is a parallelogram.
  Then $D'$ also lies in the same plane as $ABCD$,
  but is situated directly above $D$
  (since the table was a square).
  This implies $D' = D$, as needed.
\end{proof}
In still other words, we are counting the number of solutions to
\[ (n-k_1) + (n-k_3) = (n-k_2) + (n-k_4)
  \iff k_1 + k_3 = k_2 + k_4. \]
Define
\[ a_r = \# \{(a,b) \mid a+b=r, \; 0 \le a,b \le n \} \]
so that the number of solutions to $k_1 + k_3 = k_2 + k_4 = r$
is just given by $a_r^2$.
We now just compute
\begin{align*}
  \sum_{r=0}^{2n} a_r^2 &= 1^2 + 2^2 + \dots + n^2 + (n+1)^2 + n^2 + \dots + 1^2 \\
  &= \frac{1}{3}(n+1)(2n^2 + 4n + 3).
\end{align*}