Store list of integers and iterate through.

I'm attempting to create a pathfinding system using markers in a data pack. I plan to have markers each with their own tag (1,2,3,4,etc). I will then have a list of integers, I.e(1,3,2,4) which can be iterated over, meaning the mob will travel between the markers on that order. I will move the mob like this: tp @s ^1 ^ ^ facing entity @e[type=marker, tag=$(chosen_marker) Where chosen marker is replaced by a macro. How would I go about storing a list lile this, and then iterating through it?
Continue to help post