Sum of the first N numbers using std::accumulate
C++
Easy
STL
Task «Sum of the first N numbers using std::accumulate»
Write a program that reads a natural number N, then N integers, and outputs their sum. Use the std::accumulate algorithm from the STL to compute the sum. Input data: the first line contains an integer N (1 ≤ N ≤ 1000), the second line contains N integers separated by spaces. Output a single integer — the sum of the entered numbers.
Input Format
Integer N, then N integers separated by spaces.
Output Format
One integer — the sum.
Examples
Example 1
INPUT
5
1 2 3 4 5
OUTPUT
15
Example 2
INPUT
3
-1 -2 -3
OUTPUT
-6
main.cpp