4. (6) 2015 coins are placed in 5 chests. The number of coins in the chests are 5 consecutive numbers. Ivan the Fool can take 4 coins from any chest and distribute them among the remaining chests. He can repeat this operation as many times as he wants. At any point, Ivan can take all the coins from one chest. What is the maximum number of coins Ivan the Fool can take?
Solution: Notice that initially, the chests contain 401, 402, 403, 404, and 405 coins. All these numbers have different remainders when divided by 5. When performing our operation, the set of remainders when divided by 5 remains unchanged. Thus, we will leave at least \(0+1+2+3=6\) coins, resulting in a set of coins \(0,1,2,3,2009\) (this can be achieved by subtracting 4 coins from the first four chests as long as possible).