It would be much easier to just do a loop to put the numbers into an array if your numbers never drop below 0. C=0 REPEAT READ I IF I > -1 THEN ARR[C] = I INC C UNTIL I == -1