I would use a stack. Stacks work in a "first in last out" manner, meaning the first value entered will be the last output. Start with the value at "size" (which is how big the stack is) and work your way down to position 0. This is just my interpretation, there are probably many other (and better) ways to accomplish this as Tom Gunn and firstPerson have already demonstrated.
Ps. Sorry if you already know about stacks and my post was completely boring =)