Śrīmad-Bhāgavatam · Text 4.8.34
Who is speaking and story frame
गुणाधिकान्मुदं लिप्सेदनुक्रोशं गुणाधमात् ।
मैत्रीं समानादन्विच्छेन्न तापैरभिभूयते ॥ ३४ ॥
guṇādhikān mudaṁ lipsed
anukrośaṁ guṇādhamāt
maitrīṁ samānād anvicchen
na tāpair abhibhūyate
Every man should act like this: when he meets a person more qualified than himself, he should be very pleased; when he meets someone less qualified than himself, he should be compassionate toward him; and when he meets someone equal to himself, he should make friendship with him. In this way one is never affected by the threefold miseries of this material world.
Read Śrīla Prabhupāda's purport on Vedabase.io