## A Very Big Sum

In this post we will be covering **A Very Big Sum**, in which we have to calculate the total sum of all the elements present in
an array, keeping in mind that the value of the element present in the array can be
much larger and hence to calculate the sum that can be displayed without an
error, The solution is carried out in C++ with the required sets of variables,
initializations, looping and output to get.

### Problem Definition

In this challenge, you are required to calculate and print the sum of the elements in an array, keeping in mind that some of those integers may be quite large.

#### Function Description

Complete the aVeryBigSum function in the editor below. It must return the sum of all array elements. aVeryBigSum has the following parameter(s):

- int ar[n]: an array of integers.

#### Return

- long: the sum of all array elements

#### Input Format

The first line of the input consists of an integer n.

The next line contains space-separated integers contained in the array.

#### Output Format

Return the integer sum of the elements in the array.

##### Sample Input

5 1000000001 1000000002 1000000003 1000000004 1000000005

##### Sample Output

```
5000000015
```

### Let's write the code for Problem

We will be solving this problem using long Int datatype, if you do not know about it and want to explore and know more then check out this article on datatypes from tutorialspoint

#### Code Solution

#include <bits/stdc++.h> using namespace std; int main() { long int n,i,s=0; cin>>n; long int a[n]; for(i=0;i<n;i++) { cin>>a[i]; s+=a[i]; } cout<<s; return 0; }

### Sample Test Case Passed Successfully

Note: This problem and its description are taken from HackerRank - Solution is provided by The Coding Bro and in sole purpose of Education and learning - Visit HackerRank to solve more problems.

If you liked this post, then share this with your friends and if anything is confusing or incorrect then let me know in the comment section.

Thanks from my side, this is Mayank, keep learning and exploring !!