fork download
  1. import java.util.Scanner;
  2.  
  3. public class Main {
  4. public static void main(String[] args) {
  5.  
  6. Scanner scanner = new Scanner(System.in);
  7.  
  8. long N= scanner.nextLong();
  9. long []arr= new long[(int)N];
  10. for(int i=0;i<N;i++){
  11. arr[i]= scanner.nextInt();
  12. }
  13. long sum=0;
  14. for(int i=0;i<N;i++){
  15. sum+=arr[i];
  16. }
  17. System.out.println(Math.abs(sum));
  18.  
  19.  
  20.  
  21. scanner.close();
  22. }
  23. }
  24.  
Success #stdin #stdout 0.14s 56676KB
stdin
4
7 2 1 3
stdout
13