Solution
In order to add values to the array, you need to keep track of the elements already in the array. To maintain previous data, you need to use
shift registers.
Below is an image showing an example of implementing shift registers to maintain the values previously added to the array.