Then you're not dealing with a single value as you claimed. You want to iterate over a list of values. Why do you think it's a problem storing that list in an array?
As for how, you've already been shown how. You were even given a fully functional program.