perl -E "@sr=sort{$a<=>$b}@ar=(5..7,8,10,-3);map{$h{$_}++}$sr[0]..$sr[-1],@ar;say for grep{$h{$_}==1}sort{$a<=>$b} keys %h" -2 -1 0 1 2 3 4 9