Changes to array not reflected
You got confused here:

Serial.print(data[idx]);


You're printing array slice 5 (the sixth entry in a 5 entry array) 5 times.

You probably meant to write:

Serial.print(data[i]);


To improve clarity you may want to #define it instead:

#define DATA_SIZE 5
uint16_t data[DATA_SIZE];

... 

for (int i = 0; i &lt; DATA_SIZE; i++) {
    ....
}


Or you can do it the other way round (get the size from the array):

uint16_t data[5];
#define DATA_SIZE (sizeof(data) / sizeof(data[0]))