This removes the first 5, so is wrong, if you can findout how to do an inverted head (remove head), then you will have the answer. A combination of wc and tail may do it.
atq | sort -g | head -5 | cut -f1 | xargs atrm Correct answer
atq | sort -g | tail -n +6 | cut -f1 | xargs atrm