Worked on topcoder 11527