Create detect cycle in an array