Array Sum

Given an array of length N, you need to find and print the sum of all elements of the array.
Input Format :
Line 1 : An Integer N i.e. size of array
Line 2 : N integers which are elements of the array, separated by spaces
Output Format :
Sum
Constraints :

1 <= N <= 10^6
Sample Input :
3
9 8 9
Sample Output :
26

Solution :

  1. ## Read input as specified in the question.
  2. ## Print output as specified in the question.
  3. N = int(input())
  4. list = [int(x) for x in input().split()]
  5. sum = 0
  6. for ele in list:
  7. sum += ele
  8. print(sum)
Previous Post Next Post