4. We have a certain number of boxes and a certain number of balls. If we put exactly one ball in each box, we will have n balls left. However, if we set aside exactly n boxes, we can distribute all the balls so that there are exactly $n$ balls in each of the remaining boxes. How many boxes and how many balls do we have?
SOLUTION. If we denote $x$ as the number of boxes and $y$ as the number of balls, the problem leads to the system of equations

$$
x+n=y \quad \text { and } \quad(x-n) \cdot n=y
$$

with unknowns $x$, $y$, and $n$ from the set of natural numbers. By eliminating the unknown $y$, we get the equation $x+n=(x-n) \cdot n$, which has no solution for $n=1$. For $n \geqq 2$, we obtain

$$
x=\frac{n^{2}+n}{n-1}=n+2+\frac{2}{n-1},
$$

from which we see that the (natural) number $n-1$ must be a divisor of the number 2. Thus, $n \in\{2,3\}$. Substituting the permissible values of $n$ into (1) and solving the system (or using the last relation), for $n=2$ we get $x=6, y=8$ and for $n=3$ we determine $x=6$ and $y=9$.

Verification: Suppose we have six boxes and eight balls. If we put exactly one ball in each box, $n=2$ balls will remain. However, if we remove two boxes, we can distribute the balls into the remaining four boxes, each getting exactly two balls. The conditions of the problem are thus satisfied. For six boxes and nine balls, the verification is equally straightforward.

Conclusion: We either have six boxes and eight balls, or six boxes and nine balls.