Added bool array to keep track of initial numbers.