SherlockAndArray solution