All problems

Problem 21

Sum of Array

Easy · 10 pts · Array

Problem

You are given an array of N integers. Print the sum of all its elements. The elements can be negative, and each can be as large as one billion in absolute value. With up to 100,000 elements, the total can reach 10^14, which does not fit in a 32-bit integer. Use a 64-bit type (long long in C++, long in Java) for the running total.

Input

First line: integer N. Second line: N space-separated integers.

Output

Print the sum of the array.

Constraints

1 <= N <= 100000; -1000000000 <= A[i] <= 1000000000 (the sum fits in a 64-bit integer)

Example input

4
1 2 3 4

Example output

10

Explanation

The array is 1 2 3 4. Adding the elements one by one gives 1, 3, 6 and finally 10, so the sum is 10.

Every problem here can be used in a RelayTrixCode team match. Create a room.

Previous: Climbing Stairs Next: Minimum and Maximum