Given array a of length n. Find the sum of its elements.
First line contains number of elements n (1 ≤ n ≤ 10^5
) in array.
Second line contains n integers a[1]
, a[2]
, ..., a[n]
(1 ≤ a[i]
≤ 10^6
) - the array 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#
n - size of array;
a - array of integers;
function must return one integer - the sum of all array elements.
One integer will be printed - the sum of array elements.
(5 points) n ≤ 1;
(15 points) n ≤ 100, a[i]
≤ 100;
(30 points) n ≤ 10^4
, a[i]
≤ 10^4
;
(50 points) without additional restrictions.