Pokemon games use a secure value with saves, intended to stop duplication of pokemons with save backup abuse. Basically the save is tied to that specific installation by the game counting how many times it's been launched and matching that with the secure value stored in the save file (at least that's how I hear it works).
JK's Save Manager should be able to export the secure value from the old CIA's save (when it was formerly installed) and you could import it into the clean copy.
But since you've deleted it already, you'll just have to wait until someone patches Pokemon Sun/Moon support into the Secure Value Patcher tool, that lets you fix the saves manually for importing.
Or you could just delete the current secure value like that other guy said if that works, I have no idea.