The cashier at the gallery sells tickets to visitors with a number according to the order in which they came that day. The first visitor gets a ticket with the number 1, the second with the number 2, etc. However, during the day, the yellow paper on which the tickets were printed ran out, so the cashier had to continue printing on red paper. Throughout the day, she sold as many yellow tickets as red ones. She found that the sum of the numbers on the yellow tickets was 1681 less than the sum of the numbers on the red tickets. How many tickets did she sell that day?

(M. Mach)

Idea. Notice by how much the numbers on the sold yellow and red tickets differ.
Let the number of yellow tickets be $n$. The first yellow ticket had the number 1, the second had 2, and so on, with the last yellow ticket having the number $n$. The first red ticket had the number $n+1$, the second red ticket had $n+2$, and so on, with the last red ticket having the number $2n$.

Notice that the first red ticket has a number that is $n$ greater than the first yellow ticket. Similarly, the second red ticket has a number that is $n$ greater than the second yellow ticket; this applies to all such pairs of tickets, of which there are $n$ in total. Therefore, the sum of the numbers on the red tickets is $n^2$ greater than the sum of the numbers on the yellow tickets. From the problem, we know that $n^2 = 1681$, so $n = 41$.

The cashier sold 41 yellow and 41 red tickets that day, for a total of 82 tickets.