solution for Array exercise 5