Sum of array elements
Swift
Easy
arrays
Task «Sum of array elements»
Given an array of integers. Write a program that calculates the sum of all elements of the array. The array is entered from the keyboard: first the number of elements is entered, then the elements themselves. The program should output one number — the sum of the elements.
Input Format
First line — integer N (1 ≤ N ≤ 1000). Second line — N integers separated by spaces.
Output Format
One integer — the sum of the array elements.
Examples
Example 1
INPUT
3
1 2 3
OUTPUT
6
Example 2
INPUT
4
10 20 30 40
OUTPUT
100
main.swift