Rearranging + dynamic array