Every integer N satisfies at least one of the congruences N≡0(mod2), N≡1(mod3), N≡3(mod4), N≡5(mod6), N≡9(mod12). Therefore n can be 5. We will show that n≤4 is not possible.
Let 1<k1≤k2≤⋯≤kn and a1,a2,…,an be integers, and let K=lcm(k1,k2,…,kn). Since at most k1K+k2K+⋯+knK integers from 1 to K can satisfy at least one of the congruences x≡ai(modK) for 1≤i≤n, we must have k11+k21+⋯+kn1≥1 if every integer satisfies at least one of these congruences.
Now assume that 1<k1<k2<⋯<kn and a1,a2,…,an satisfy the condition of the problem and that n≤4 has the smallest possible value. If k1=3, then k11+k21+⋯+kn1≤31+41+51+61=2019<1. Therefore k1=2.
Without loss of generality we may assume that a1=1. For 2≤i≤n, let ki′=ki and ai′=2−1ai(modK) if ki is odd, and let ki′=2ki and ai′=2ai if ki is even. The integers k2′,…,kn′ and a2′,…,an′ satisfy the condition of the problem except that ki′ might not be distinct. Therefore by the minimality of n, we must have n=4 and {k2,k3,k4}={2m+1,4m+2,k}.
* If k is odd, then {k2′,k3′,k4′}={2m+1,2m+1,k} and 2m+12+k1≥1. Since 2m+12+k1≤32+51=1513<1, this is not possible.
52+42=109<1 and 32+82=1211<1. The only remaining case is 2m+1=3 and k=4. This gives {k2′,k3′,k4′}={3,3,2}. Since the integers in a congruence class modulo 3 cannot be all even or all odd, this also leads to a contradiction.
* If k is even, then {k2′,k3′,k4′}={2m+1,2m+1,2k} and 2m+12+k2≥1. If 2m+1≥5 or 2m+1=3 and k≥8, we get contradictions because
52+42=109<1 and 32+82=1211<1.
The only remaining case is 2m+1=3 and k=4. This gives {k2′,k3′,k4′}={3,3,2}. Since the integers in a congruence class modulo 3 cannot be all even or all odd, this also leads to a contradiction.
Therefore, the smallest possible value of n is 5.