extracts repeated elements as arrays