Proverbs 11:8

11:8 The righteous person is delivered out of trouble,

and the wicked turns up in his stead.

Proverbs 21:18

21:18 The wicked become a ransom for the righteous,

and the faithless are taken in the place of the upright.