I have a bunch of variables named index1, index2, ..., indexn. I want to calculate i = array[index1] + array[index2] + ... + array[indexn].
I heard that I can do that in a loop, getting the current variable name from the loop index. How can I do that?