• + 0 comments

    Collections.sort(arr);

    long Max=0L;
    long Min=0L;
    
    for(int A =0;A<arr.size();A++){
        if(A!=0){
            Max=Max+arr.get(A);
        }
    }
    
    for(int B = arr.size()-1;B>-1;B--){
        if(B!=arr.size()-1){
            Min=Min+arr.get(B);
        }
    }
    
    System.out.print(Min + " " +Max);