I ran into a similar problem yesterday and found a solution similar to what Russ suggested.
I am including a diagram of my solution, which replaces Russ' case structure with a Select. When the array element is not zero (True), the shift register input on the right side receives the shift register output from the left side. However, when the element is zero (False) I first add the current loop index to the array stored in the shift register.
For a large array, my solution may be slower than what Russ suggested. However, I like not having an unnecessary case structure.
Scot