distinct terms in given sequence