improve Calculate Distance, Unique Elements, N Mod M, Sum of integers

Bash