If I have a constraint like $x_1 + x_2 +\dots + x_n = k$ for positive integers $x_i$, how would I minimize $$\text{minimize}\quad\frac{a_1 }{ x_1} + \frac{a_2 }{ x_2} + \frac{a_3 }{ x_3} + \dots + \frac{a_n }{ x_n}$$ if all of the $a_i$ are given?
One can assume that $n\le5\cdot10^5$ and $k\le10^{12}$.