Al-A'raf - 7:165

فَلَمَّا نَسُواْ مَا ذُكِّرُواْ بِهِ أَنجَيْنَا الَّذِينَ يَنْهَوْنَ عَنِ السُّوءِ وَأَخَذْنَا الَّذِينَ ظَلَمُواْ بِعَذَابٍ بَئِيسٍ بِمَا كَانُواْ يَفْسُقُونَ
[7:165]
So when they neglected what they had been reminded of, We delivered those who forbade evil and We overtook those who were unjust with an evil chastisement because they transgressed.
When they disregarded the warnings that had been given them, We rescued those who forbade Evil; but We visited the wrong-doers with a grievous punishment because they were given to transgression.
And when they forgot that whereof they had been reminded, We rescued those who forbade wrong, and visited those who did wrong with dreadful punishment because they were evil-livers.