Created
February 15, 2016 14:45
-
-
Save husnain-iqbal/d5874b6cb13633bab6f1 to your computer and use it in GitHub Desktop.
You are given an array of integers of size NN. You need to print the sum of the elements in the array, keeping in mind that some of those integers may be quite large. Input The first line of the input consists of an integer NN. The next line contains NN space-separated integers contained in the array. Constraints 1≤N≤101≤N≤10 0≤A[i]≤10100≤A[i]≤1…
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.io.*; | |
import java.util.*; | |
import java.text.*; | |
import java.math.*; | |
import java.util.regex.*; | |
public class Solution { | |
public static void main(String[] args) { | |
Scanner in = new Scanner(System.in); | |
int n = in.nextInt(); | |
int arr[] = new int[n]; | |
long sum = 0 ; | |
for(int arr_i=0; arr_i < n; arr_i++){ | |
arr[arr_i] = in.nextInt(); | |
sum += (long) arr[arr_i]; | |
} | |
System.out.println(sum); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment