Solves http://www.spoj.com/problems/ADDREV/