5. On the table, there are 140 different cards with numbers $3,6,9, \ldots 417,420$ (each card has exactly one number, and each number appears exactly once). In how many ways can 2 cards be chosen so that the sum of the numbers on the selected cards is divisible by $7?$
Answer: 1390.

Solution. The given numbers, arranged in ascending order, form an arithmetic progression with a common difference of 3. Therefore, the remainders when these numbers are divided by 7 alternate. Indeed, if one of these numbers is divisible by 7, i.e., has the form $7k$, where $k \in \mathbb{N}$, then the numbers following it are $7k+3, 7k+6, 7k+9=7(k+1)+2, 7k+12=7(k+1)+5, 7k+15=7(k+2)+1, 7k+18=7(k+2)+4$, which give remainders $2, 4, 6, 1, 3, 5$ respectively when divided by 7. Next comes the number $7k+21$, which is divisible by 7, and then the remainders repeat. Thus, the remainders when the given numbers are divided by 7 go in the order $\ldots 0; 3; 6; 2; 5; 1; 4; 0 \ldots$

Among the 140 given numbers, there are 20 numbers that give remainders $0, 1, 2, 3, 4, 5, 6$ when divided by 7.

The sum of two numbers can be divisible by 7 in the following cases.

1) Both numbers are divisible by 7. There are 20 cards with such numbers, and we need to choose 2 of them - there are $C_{20}^{2} = \frac{1}{2} \cdot 20 \cdot 19 = 190$ ways to do this.
2) One of the numbers gives a remainder of 1 when divided by 7 - then the other must give a remainder of 6 when divided by 7. This pair of numbers can be chosen in $20 \cdot 20 = 400$ ways.
3) One of the numbers gives a remainder of 2 when divided by 7 - then the other gives a remainder of 5, and, similarly to the second case, there are 400 ways to choose 2 numbers.
4) One of the numbers gives a remainder of 3 when divided by 7 - then the other gives a remainder of 4 - also 400 ways.

In total, there are 1390 ways.