problem 4 (with arrays)