Given array of length . Find the sum of its elements.
Implement the function:
long long solve(int n, vector <int> arr); // C++
function solve(const n :integer; const arr: array of integer) : integer; // Pascal
public static int solve(int n, int []arr); // Java
def solve(n, arr); // Python
static long solve(long n, long [] arr); // C#
- size of array;
- array of integers;
function must return one integer - the sum of all array elements.
First line contains number of elements (1 \leq n \leq 10^5) in array.
Second line contains integers a_1, a_2, ..., a_n (1 \leq a_i \leq 10^6) - the array elements.
One integer will be printed - the sum of array elements.
Example 1
Example 2
( points) n \leq 1;
( points) n \leq 100, a_i \leq 100;
( points) n \leq 10^4, a_i \leq 10^4;
( points) without additional restrictions.