modulo-N residue