Cycle through an array to select only a particular index and a specified number of neighbours.