We will show that the smallest n satisfying the condition of the problem is 20122.
First, let us show that if n=20122, then there exists a method of selecting cards at each stage so as to satisfy the condition of the problem. For this purpose, let for each k≥1, select 2012 cards to be drawn in the k-th stage in the following way:
Write k=2012q+r for some choice of q≥0 and 1≤r≤2012, and choose 2012−r cards, each of which has the number q written on it, and choose r cards, each of which has the number q+1 written on it.
Let us check that this method to keep on choosing cards satisfies the condition of the problem. There are the following two facts to be checked:
(1) The sum of the numbers written on the cards at the k-th stage must equal k.
(2) For every integer a≥0, there are at most 20122 cards with the attached number a among the selected cards throughout the whole procedure.
We see that the condition (1) is satisfied, since
q(2012−r)+(q+1)r=2012q+r=k
holds, because of the way q and r are chosen.
To show that the condition (2) is satisfied, we first consider the case where a≥1. Then for any r satisfying the condition 1≤r≤2012, 2012−r cards each with the number a attached are selected at the (2012a+r)-th stage, and r cards each with the number a attached are selected at the (2012(a−1)+r)-th stage. Therefore, the total number of the cards with the number a attached which are selected in the whole procedure equals
r=1∑2012((2012−r)+r)=(2011+2010+⋯+0)+(1+2+⋯+2012)=22011⋅2012+22012⋅2013=20122,
which shows that the condition (2) is satisfied for each a≥1.
Finally, if a=0, we see that for each r, with 1≤r≤2012, 2012−r cards with 0 attached are selected at the r-th stage so that the total number of cards with 0 attached chosen in the whole process is
r=1∑2012(2012−r)=r=1∑2011r=22011⋅2012<20122,
which shows that the condition (2) is satisfied for a=0 as well, and this completes the proof that if n=20122, then there is a method to keep on choosing cards at each stage so as to satisfy the condition of the problem.
Next, we show that if there is a method of choosing cards at each stage so as to satisfy the condition of the problem, then we must have n≥20122. For this purpose, let k be an arbitrary positive integer and keep on choosing the cards at each stage according to the method which is supposed to satisfy the condition of the problem. Then, the sum of all the numbers attached to 2012nk cards selected by the end of the (nk)-th stage must be, because of the condition of the problem,
j=1∑nkj=21nk(nk+1).
On the other hand, since for each j≥0 there are exactly n cards having the number j attached, the sum of all the numbers attached to the 2012nk cards selected must be greater than or equal to
nj=0∑2012k−1j=n⋅22012k⋅(2012k−1).
Therefore, we must have
2nk(nk+1)≥n⋅22012k(2012k−1),
which can be simplified to
n≥20122−k2013.
Since k can be any positive integer, we take k=2014 to conclude that n≥20122 must be satisfied.