Problems > Sum of an Array

Sum of an Array

Difficulty: 800 2000 ms 128 MB

implementation

Given a list of integers, print their sum.

Input: the first line has an integer N; the second line has N integers separated by spaces.

Output: one integer — the sum of the N values.

Constraints:

  • 1 ≤ N ≤ 2000
  • −109 ≤ ai ≤ 109

Sample Tests

Input 1
4
3 -1 10 5
Output 1
17
Input 2
2
-7 -8
Output 2
-15

Read the Editorial

Discussion (opens after you solve — no spoilers before)

No comments yet.

Submit Your Solution

Log in or create a free account to run and submit code.