mean and median, group line elements together