When you index into an array with just one index, you're using a technique called linear indexing. This basically treats your array like it was one long vector, as described in the "Indexing with a Single Index" section on this documentation page. You want to perform subscripted indexing, as Fangjun Jiang suggested and as the "Indexing with Element Positions" section on that documentation page states. That section mentions the end keyword will will be very useful in keeping your code generalized. This avoids hard-coding in the size of a particular array, letting your code automatically handle different sized inputs without needing modification.