Is a sum of n terms considered O(1) or O(n)?
If you have ten elements, then that's a constant and considered $O(1)$.  However, if you're given an input to a function, and want to analyze the running time of your algorithm in terms of the input length, then that's $O(n)$, provided that you at least read the entire array (and $n$ is the array length).

It all has to do with what you measure your running time in.  In parameterized complexity, for instance, we typically measure the complexity in two parameters; the length of the input, and an additional parameter $\kappa$.  Hence, there you will often see running times like $O(n \cdot 2^\kappa)$.

In your problem, we say $O(n)$ because we sometimes consider "summing integers" as a constant operation.  That's obviously not possible if we allow arbitrarily large integers.  If the max (absolute) integer is $N$, then your algorithm might be $O(n \log N)$.