Might I suggest using `processed |= A` instead of checking the contents of the list each time?  I've found this to be around 13-14x faster in super large lists, though that may not be the case here.