Sum of array elements#698

Sum of array elements

1 second
128 megabytes
Very easy (≈850)

Given array a of length n. Find the sum of its elements.

Interaction protocol

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#

Input

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.

Output

One integer will be printed - the sum of array elements.

Grading

  1. (5 points) n ≤ 1;

  2. (15 points) n ≤ 100, a[i] ≤ 100;

  3. (30 points) n ≤ 10^4, a[i] ≤ 10^4;

  4. (50 points) without additional restrictions.

Examples

Example 1

Loading
Loading

Example 2

Loading
Loading