solution for Array example 4