print once every value of multiple occurrences - sorted array