solution for Array exercise 7