Storing 2D arrays in linear storage (1D array)