Valmiki Ramayana Sundara Kanda Sarga 26 Shloka 50
Original Shlokaप्रियान्न संभवेद्दुःखमप्रियादधिकं भयम्।।5.26.50।। ताभ्यां हि ये वियुज्यन्ते नमस्तेषां महात्मनाम्।
1 source checked for this shloka
प्रियात् from a pleasing act, दुःखम् sorrow, अप्रियात् from an unpleasant act, अधिकम् excessive, भयम् fear, न संभवेत् may not result, ये those, ताभ्याम् from both of them, वियुज्यन्ते those who have distanced themselves, तेषाम् for them, महात्मानाम् of the great sages, नमः salutations to them.
"Salutations to those exalted souls who have distanced themselves from pleasure and displeasure. Pleasures may not lead to suffering or displeasure to excessive, meaningless fear for such great souls.