How to find area under the curve of a signal?
How precise does the measurement have to be? If it doesn't have to be super precise, try using a float type instead of long int. After each result, divide by some arbitrary constant to keep the numbers lower. Sum these smaller numbers, then multiply the final result by the same constant. You will lose some precision, but likely will get the result you want.