8. A set of natural numbers is called bad if it is possible to select several numbers from it such that their sum equals 2012. Find the smallest such $n$ that the numbers $503, 504, \ldots, 2011$ can be partitioned into $n$ sets such that none of these sets are bad.
Answer: $n=2$.

Solution: We will show that the given set can be divided into two subsets, neither of which are bad. Consider the sets $M_{1}=\{503,504, \ldots, 671\}$, $M_{2}=\{672,673, \ldots, 1006\}$, $M_{3}=\{1007,1008, \ldots, 1340\}$, $M_{4}=\{1341,1342, \ldots, 2011\}$, and show that $M_{1} \cup M_{3}$ and $M_{2} \cup M_{4}$ are not bad.

We will prove that $M_{1} \cup M_{3}$ is not bad. Consider the cases:

- Four numbers from the set $M_{1}$ give a sum $S \geqslant 503+504+505+506=$ $2018>2012 ;$
- Three numbers from the set $M_{1}$ give a sum $S \leqslant 669+670+671=2010<2012$
- One number from the set $M_{1}$ and one from $M_{3}$ give a sum $S \leqslant 671+1340=$ $2011<2012$;

Similarly, it can be proven for $M_{2} \cup M_{4}$.