So I will explain...
indeed the while function ends. Because of the condition, i<n. I am only using n to define the number of positions of the array and limiting the while.
If you go see inside the while when I press the button I read the position of the potentiometer and save this position to the first position of the array and I do an increment on i variable (i++);
So when I press the second time the button the same process appends but for the last time because i variable now is i=2 and the condition of while was while(i<n). If you see n is defined as 2. So we are not inside the while anymore and we are now in the second part of the code the part of memory mode, so in this time I have already the values from potentiometer saves in arrays so there I converted the values to 0 to 180 degrees, and then send this values.
I clear some of the comments and left some of them because I was just testing for one servo motor. But I have made the code for the 5.
I hope it is helpful, by the way, you are awesome, always here to help. I just want to say thanks just for the attention.