1D array to ND array