This is the code I used for this problem.
integer array(20) userInt integer i
i = 0 userInt[i] = Get next input
for i = 1; userInt[i - 1] >= 0; i = i + 1 userInt[i] = Get next input
if i - 1 >= 10 Put "Too many inputs" to output else i = i - 1 Put userInt [i / 2] to output