Compress consecutives duplicates elements