Problem 5 of Arrays with Custom Solution