So the id is read into the A array and a loop captures the matching lengths. I am not sure what X or i is? Sorry scientist trying to learn. Thank you :).
The A is an associative array, meaning that index is not an ordered sequence of numbers, but an string. In order to get back the value you need to know the "index". for(i in A) is the way that AWK iterate over the A array, setting i to an "index" at each iteration. The disadvantage is that the order may no be as it was taken from the file nor it is guarantee to be the same order each time you run the program.