Solution by Leo Manfredi