Problem 2 of array with custom solution