Replace loop + delete with array difference