Thanks to Szemerédi's theorem on sets with no long arithmetic progressions, an elementary trick is used here to show that for a given positive integer $h$ and a given set $U$ of residue classes modulo $n$ with positive density, there exists a dense subset $V$ of $U$; that is, $U\smallsetminus V$ is very small, such that the sumset $hV$ is included in the restricted sumset $h\times U$. The next step is to obtain information on the structure of $V$ from Kneser's theorem on the sum of sets in an abelian group, and to use this for studying the structure of $U$ itself. Finally, this idea is used in the paper to derive some new values of a function related to the Erdős–Ginzburg–Ziv theorem.