eolymp
bolt
Try our new interface for solving problems
Problems

Sum of array elements

Sum of array elements

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#

  • n - size of array;
  • a - array of integers;
  • function must return one integer - the sum of all array elements.

Input

First line contains number of elements n (1n105) in array.

Second line contains n integers a1, a2, ..., an (1ai106) - the array elements.

Output

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

Grading

  1. (5 points) n1;
  2. (15 points) n100, ai100;
  3. (30 points) n104, ai104;
  4. (50 points) without additional restrictions.
Time limit 1 second
Memory limit 128 MiB
Input example #1
5
2 3 8 1 3
Output example #1
17
Input example #2
1
7
Output example #2
7