A class has $n$ students. No matter how two students are chosen, at least one of them has already had lunch at the other's place. In addition, each student has hosted for lunch exactly one quarter of the students at whose place they have had lunch.

Determine all possible values of $n$.
Let $\mathbf{E}_{1}, \ldots, \mathbf{E}_{n}$ be our students. We denote $a_{k}$ as the number of students with whom $\mathbf{E}_{k}$ has had lunch, and $b_{k}$ as the number of students that $\mathbf{E}_{k}$ has invited to lunch. The statement indicates that these $b_{k}$ students are, on the one hand, the $n-1-a_{k}$ students with whom $\mathbf{E}_{k}$ has not had lunch, and, on the other hand, $a_{k} / 4$ of the students with whom $\mathbf{E}_{k}$ has had lunch, so that $b_{k}=n-1-3 a_{k} / 4$.

We will now count the number of meals, denoted by $\mathbf{C}$, in two different ways. On the one hand, it is the number of times a student has had lunch at a friend's place, so $\mathbf{C}=a_{1}+\ldots+a_{n}$. On the other hand, it is also the number of times a student has invited a friend to lunch, so $\mathbf{C}=b_{1}+\ldots+b_{n}$. We deduce that

$$
\mathbf{C}=\sum_{1 \leqslant k \leqslant n} b_{k}=\sum_{1 \leqslant k \leqslant n}\left(n-1-3 a_{k} / 4\right)=n(n-1)-3 \mathbf{C} / 4,
$$

which means that $7 \mathbf{C}=4 n(n-1)$. Thus, 7 divides $n$ or $n-1$.

We could also have obtained this result by counting the number of pairs $(a, b)$ where $a$ and $b$ are two distinct students such that $a$ has eaten at $b$'s place and $b$ has eaten at $a$'s place: we say that such a pair is pretty and denote $N$ as the number of pretty pairs. Indeed, for a fixed $a$, there are 4 times fewer $b$ such that $(a, b)$ is pretty than the number of pairs $(a, b)$ such that $a$ has had lunch at $b$'s place, so four times fewer than the number of meals. There are $N / 2+\binom{n}{2}$ meals because if we choose two students, one has eaten at the other's place (the $N / 2$ comes from the fact that we count only once for both $(a, b)$ and $(b, a)$ being pretty), so $7 N=2\binom{n}{2}$, and we obtain the same result.

We know, therefore, that 7 divides either $n$ or $n-1$, and we study these two cases separately:

- If 7 divides $n-1$, let $\ell=(n-1) / 7$. Below, we identify the students with the elements of $\mathbb{Z} / n \mathbb{Z}$. One way to achieve the situation described in the statement is that each student $k$ goes to lunch at the places of students $k+1, k+2, \ldots, k+4 \ell$ (i.e., $4 \ell$ students), and thus receives $k-4 \ell, \ldots, k-1$ (i.e., $\ell$ students). Indeed, since $-4 \ell \equiv 3 \ell+1(\bmod n)$, the students who have invited $k$ to lunch and have had lunch with him are the students $k+3 \ell+1, \ldots, k+4 \ell$ (i.e., $\ell$ students).
- If 7 divides $n$, let $\ell=n / 7$. This time, we identify the students with the elements of $\mathbb{Z} /(n-1) \mathbb{Z}$, as well as a special element, which we will denote by $\bullet$. We decide that the student $\bullet$ will receive everyone for lunch but will not go to anyone's place, and that each student $k$ (with $k \neq \bullet$) will go to lunch at $k+1, \ldots, k+4 \ell-1$, $\bullet$ (i.e., $4 \ell$ students), and will receive the students $k-4 \ell+1, \ldots, k-1$ for lunch. This time, since $-4 \ell+1 \equiv 3 \ell$ $(\bmod n-1)$, the students who have invited $k$ to lunch and have not had lunch with him are the students $k+3 \ell, \ldots, k+4 \ell-1$ (i.e., $\ell$ students).

Therefore, the possible values of $n$ are all integers $n$ such that $n \equiv 0(\bmod 7)$ or $n \equiv 1(\bmod 7)$.