Exit condition for loop = - 1 when n has reached 1
while ( a . get ( 1 ) != - 1 ) { sequence . add ( a . get ( 1 ) ) ; Vector < Integer > arr = find_sequence ( a . get ( 1 ) ) ; a . set ( 1 , arr . get ( 1 ) ) ; }