ספר המדות, A Righteous Person / Part I A Righteous Person / Part I · רו
Sefer HaMiddot 2217
רו. הַצַּדִּיק כְּשֶׁמִּתְפַּלֵּל עַל הָאָדָם, הוּא מֵבִין עַל אֵיזֶה עֲבֵרָה בָּא עָלָיו הַפֻּרְעָנוּת הַזֹּאת.
206. The Tzaddik -- when he prays on behalf of someone, he can discern from which sin this suffering came upon the person (t.n. The commentaries do not provide any citation here, so I suggest the instance of where G-d tells Avimelech (Beraishes 20:7) that Father Abraham will pray for Avimelech recovery because Abraham is a prophet, and Our Sages explain that G-d was reassuring Avimelech that Abraham would know that Avimelech had not touched Sarah, and nevertheless was punished for taking her).