123 A cube with edge length $n$ is divided into $n^{3}$ unit cubes by planes parallel to its faces. The number of pairs of unit cubes that share no more than 2 vertices is $\qquad$.
$123 \frac{1}{2} n^{2}\left(n^{4}-7 n+6\right)$. If two unit cubes have at least 3 common vertices, then they share a face. The number of unit cubes is equal to $n^{3}$, each having 6 faces, totaling $6 n^{3}$ faces, of which $6 n^{2}$ faces are on the surface of the large cube, so there are $6 n^{3}-6 n^{2}$ faces inside the large cube. These faces are counted twice, hence there are $3 n^{3}-3 n^{2}$ pairs of unit cubes sharing a face. Since there are $C_{n}^{23}$ pairs of unit cubes in total, we have
$$
C_{n}^{23}-\left(3 n^{3}-3 n^{2}\right)=\frac{1}{2} n^{2}\left(n^{4}-7 n+6\right) .
$$

For unit cubes, the number of common vertices does not exceed 2.