We construct an $n(n \geq 5)$ unit-edged cube from unit-edged white cubes, and paint the faces of this cube red. Classify the original unit-edged cubes based on the following two criteria:

a) how many red faces they have,

b) whether they have a neighbor (a cube that is connected to them by one face) that has one more red face than they do. How many (non-empty) classes will we thus sort the cubes into, and how many cubes will be in each class?
A small cube can have at most three sides painted red, since among four sides, there are always two parallel ones, and we could not have painted both of these. Three red sides have those cubes that share a common vertex with the large cube, and there are 8 such cubes in total. Since these are the best-painted cubes, they do not have a better-painted neighbor, so these 8 cubes belong to the same class according to b). We will briefly say that those cubes that do not have a better-painted neighbor are those that do not have a neighbor with one more red side.

Certainly, two red sides have those cubes whose one edge is also an edge of the large cube. If we exclude the 8 already considered from these, (n-2) remain on each edge. Among these, the two at the ends are neighbors of the 8 corner cubes, so (n-4) cubes on each edge do not have a better-painted neighbor, and there are 12 edges, so a total of 12(n-4) such cubes. The number of those that have two painted sides and do have a better-painted neighbor is 2 on each edge, a total of 24. (Among the listed ones, there is no cube that belongs to two large edges, since then it would be a corner cube, which we do not count.)

One red side has those cubes that share a face with the large cube and have not yet been considered. If we exclude the edge cubes that have appeared so far, (n-2) cubes remain in each row, a total of (n-2)^2. Among these, the edge ones again have a better-painted neighbor (and it always has exactly one more painted side); if we exclude these, (n-4) cubes remain in each row, so (n-4)^2 cubes on each face have one red side and do not have a better-painted neighbor. The number of such cubes is thus 6(n-4)^2, and those that do have a better-painted neighbor are the remaining

$$
6\left[(n-2)^{2}-(n-4)^{2}\right]=24(n-3)
$$

If we exclude the cubes already counted, (n-2) cubes remain in each row, column, and depth, so their total number is (n-2)^3. Among these, the edge ones (which share a face with the (n-2) unit edge cube formed by the remaining cubes) have a neighbor with one red side. If we exclude these as well, a (n-4) unit edge cube remains, which contains (n-4)^3 cubes: these have no red side and no better-painted neighbor. Finally, the number of those not yet counted

$$
(n-2)^{3}-(n-4)^{3}=6 n^{2}-36 n+56
$$

have no red side, but do have a better-painted neighbor.

We summarize our results in the following table. According to this, we have sorted the cubes into seven non-empty classes:

| The number of painted sides | Has a better-painted | Does not have a better-painted |
| :---: | :---: | :---: |
| 3 | - | 8 |
| 2 | 24 | $12(n-4)$ |
| 1 | $24(n-3)$ | $6(n-4)^{2}$ |
| 0 | $6 n^{2}-36 n+56$ | $(n-4)^{3}$ |