Optimizing Knowledge Integration in Retrieval-Augmented Generation with Self-Selection