Summing subsets , How to know that sum % Mod repeats after 22

can anyone please tell how can one know that result repeats after 22 in question http://www.codechef.com/problems/RESN05 , i spend a day on it but never got even close to thinking that it repeats after 22
http://www.codechef.com/problems/RESN05

even i have the same doubt ???