code/online_challenges/src/codechef/CASH/README.md
There are N bags with coins in a row (numbered 1 through N); for each valid i, the i - th bag contains A(i) coins. Chef should make the number of coins in each bag divisible by a given integer K in the following way:
The number of coins placed in the last N−c bags must not exceed the number of coins taken out from the first c bags, but there may be some coins left over. Let's denote the number of these coins by RR. You should find the smallest possible value of RR.