seletion algorithm with unknown elements number