I think you used an INT instead of a LONG for the time and purchasing count, since it flips between negative and positive when it becomes big
Even it's better to use BigInt