For positive integers it is intuitive:  a mod n gives the remainder when a is divided by n.

Example: 7 mod 4 = 3

For negative integers we use the following formula (it actually holds for all integers) a = q . n + r, where we require modulus n > 0.

Example: -11 mod 7 = 3