First, initialize your 1D array first, outside your loop. Then may be put, "true or false" case to check the condition and then you replace your data. see attach.
------------------------------------------------------------------
When you feel sad, laugh