Fix solution to problem #6 (left out last array elements)