Partitioning an array