• + 0 comments

    import java.io.; import java.util.;

    class Result {

    /*
     * Complete the 'miniMaxSum' function below.
     * The function accepts INTEGER_ARRAY arr as parameter.
     */
    
    public static void miniMaxSum(List<Integer> arr) {
        long totalSum = 0;
        long min = Long.MAX_VALUE;
        long max = Long.MIN_VALUE;
    
        for (int num : arr) {
            totalSum += num;
            if (num < min) min = num;
            if (num > max) max = num;
        }
    
        long minSum = totalSum - max; // exclude largest
        long maxSum = totalSum - min; // exclude smallest
    
        System.out.println(minSum + " " + maxSum);
    }
    

    }

    public class Solution { public static void main(String[] args) throws IOException { BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(System.in));

        String[] input = bufferedReader.readLine().trim().split(" ");
        List<Integer> arr = new ArrayList<>();
    
        for (int i = 0; i < 5; i++) {
            arr.add(Integer.parseInt(input[i]));
        }
    
        Result.miniMaxSum(arr);
    
        bufferedReader.close();
    }
    

    }