I have a sum series of large numbers (of the order of $10^{15}$) as Z. I need to find out the larges multiple of 1999 that is less than or equal to Z.
Formally,
$$Z = \sum_{i}^na_i$$
where $a_i >= 10^{15}$.
I need to find $Y$ such that $1999 *Y <= Z$. Also, since, Y could be very large, it is required to find $Y$ modulo 1000000007.
What I have done so far? I have taken modulus of each $a_i$ with 1000000007 and then calculated $Z$ by taking modulus after each summation with $a_i$. Then I just tried to divide $Z$ by $1999$ to obtain $Y$. But I strongly believe, dividing directly by $1999$ is not the proper way was I am diving the "modulated" value of $Z$ rather than actual $Z$.
Please suggest the proper way to find the $Y$.
Thank you.