Problem 9 of array Custom Solution