python split array into chunks based on value