I have a set of integers [$c_1$, $c_2$, $c_3$, ... , $c_N$]. A non-negative integer D, greater than a certain threshold, divides each 𝑐𝑖 and leaves remainder 𝑟𝑖,i.e., $r_i$ can be written as $r_i=c_i Mod D$. For all these numbers in the set, I want to find a single value of $D$ that minimizes the sum of remainders i.e. minimize $Σr_i$.
If the integers have a common divisor, this problem is easy. If the integers are relatively co-prime however, then it is not clear how to solve it.
I was thinking about solving it with Genetic Algorithm, but Genetic Algorithm is kind of slow. I want to know is there any other way to solve this problem.