Homomorphic Modular Reduction for Secure Storage
Your modulo operation does not require a real division, because you are not far from your modulus.

Represent your numbers with 2's complement by using TFHE, or HELib libraries. In this case, your numbers use bit arithmetic in FHE, i.e. you will have a cyphertext $\{c_0,c_1,\ldots,c_{k-1}\}$ for $k$-bit numbers.

What operation do you need?


$Add(A,B)$ : homomorphic addition  
$Sub(A,B) = Add(A,-B)$ : homomorphic substraction by using $Add$.
$MSB(A)$ : return the most significant bit of the ciphertext
Comparison $Comp(A,B) = MSB(Sub(A,B)) = MSN(Add(A,-B)) $
If : for singe if else case with single encrypted bit $S$, $$I = S \cdot A + S' \cdot B$$ where $\cdot$ is the $\text{AND}$ operation. According to value of $S$, $I$ is either $A$ or $B$.


More details on these operations can be found in a previous answer about common circuits in FHE.

Let $A = Enc_{pk}(A)$, $B=Enc_{pk}(b)$, and $N = Enc_{pk}(n)$ be encryption of plaintexs $a,b,\text{and } n$ under a semantically secure Fully homomoerphic Encryption with public key $pk$, where $n$ is the modulus.


$S = Sub(A,B) = Add(A,-B)$
$C = MSB(S)\quad\quad\quad\;$          //one bit comparison the result.
$F = S + N\quad\quad\quad\quad\;$      // adding modulus if needed  
$R = C * F + C' * S\quad$  // If condition on $C$ selects either $F$ or $S$.
Return $R$


The circuit is not complete because the answer can still be negative. In this case, compare with encryption of zero $E_0 =Enc_{pk}(0)$and add $N$ again.