}

Vanya receives exactly one grade ("3", "4", or "5") for each of seven subjects every week. He considers a week successful if the number of subjects with improved grades exceeds the number of subjects with worsened grades by at least two. It turned out that $n$ weeks in a row were successful, and in the last of these weeks, the grade for each subject exactly matched the grade of the first week. What could the number $n$ be?
Let's calculate the sum of Vanya's grades for each week. Let's see how the sum of grades could change on a successful week. Suppose Vanya's grades worsened in $x$ subjects. Then they improved in at least $x + 2$ subjects. Therefore, $x + (x + 2) \leq 7$, which means $x \leq 2$. The sum of grades for the subjects where the grades improved increased by at least $x + 2$, while the sum of grades for the subjects where the grades worsened decreased by no more than $2x$. Since $x \leq 2$, then $2x \leq x + 2$, meaning the decrease was no greater than the increase. Thus, the sum of Vanya's grades does not decrease, and it can remain the same only if the grades worsened by 2 in two subjects and improved by 1 in four subjects.

Since the sum of grades did not increase in the end and did not decrease each week, it remained constant throughout the observation period. Therefore, the grade reduction always occurs by 2 points, and the grade improvement by 1 point, meaning for each subject, the number of grade improvements is twice the number of grade reductions. Thus, the number of changes in each grade is a multiple of 3.

Let Vanya observe his performance for $n$ weeks, excluding the first week. Let's see what $n$ can be. Consider the following cases.

1) $n = 3k$. Below is an example of changes in Vanya's grades for $n = 3$. Repeating the last three weeks $k$ times, we get an example for $n = 3k$.

| first week | 5 5 | 53 | 3 |  | 4 E |
| :---: | :---: | :---: | :---: | :---: | :---: |
| 1st week of observations | ![](https://cdn.mathpix.com/cropped/2024_05_06_ed1a9e9dd82795d4db2eg-23.jpg?height=74&width=83&top_left_y=109&top_left_x=1093) | $3 \longdiv { 4 }$ |  |  | 5 |
| 2nd week of observations | 444 | $4 \longdiv { 5 }$ |  |  |  |
| 3rd week of observations | 5 | 53 | 3 |  | 4 |

2) Suppose $n = 3k + 1$. Consider a subject for which we know the grade changed. Since the number of changes in the grade for this subject is a multiple of 3, and $n = 3k + 1$, there was at least one week when this grade did not change. In that week, all other grades changed. Therefore, for all subjects, the grades changed at some point, and there is a week (for each subject, a different one) when the grade for that subject remained unchanged. Since there are 7 subjects, the number of weeks cannot be less than seven. Below is an example of changes in Vanya's grades for $n = 7$. Adding three weeks from the previous case, we can get any $n$ of the form $3k + 1$ greater than seven.

| first week | $\|5\|$ | 53 |  | 34 | 4 | 5 |
| :---: | :---: | :---: | :---: | :---: | :---: | :---: |
| 1st week of observations | 3 | 3 | 4 | 45 | 5 | 5 |
| 2nd week of observations | 4 | 4 | 5 | 5 | 53 | 3 |
| 3rd week of observations | 5 | 5 | 5 | 3 | 34 | 4 |
| 4th week of observations | 5 | $3:$ | 3 |  |  | 5 |
| 5th week of observations | 3 | 4 . | 4 |  | 55 | ![](https://cdn.mathpix.com/cropped/2024_05_06_ed1a9e9dd82795d4db2eg-23.jpg?height=65&width=51&top_left_y=1096&top_left_x=1355) |
| 6th week of observations | 4 | 5 | 5 | 5 | 3 | 3 |
| 7th week of observations | 5 | 5 5\|: | 3 | 32 | 44 | 4 |

3) $n = 3k + 2$. Consider a subject for which we know the grade changed. Since the number of changes in the grade for this subject is a multiple of 3, and $n = 3k + 2$, there were at least two weeks when the grade for this subject did not change, while the grades for all other subjects changed. Similarly to the previous case, for each subject, there are at least two weeks when the grade for these subjects did not change, while the grades for all other subjects changed, so the number of weeks cannot be less than 14.

An example for $n = 14$ is constructed by repeating the example for $n = 7$ twice. Clearly, we can then add three weeks from the example of the first case.

## Answer

$n \in N \backslash\{1,2,4,5,8,11\}$