Part of OIFMAT I 2010
Source: OIFMAT I 2010 day 2 p5 - Chilean Math Forum FMAT Olympiad https://artofproblemsolving.com/community/c2484778_oifmat