first array version finished, but much slower than vector version, waiting to be solved