문제 확인하기
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Collections;
import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.Stream;
class Result {
public static void miniMaxSum(List<Integer> arr) {
Collections.sort(arr);
long totalSum = 0;
for (int i : arr) {
totalSum += i;
}
long minimumSum = totalSum - arr.get(arr.size() - 1);
long maximumSum = totalSum - arr.get(0);
System.out.printf("%d %d", minimumSum, maximumSum);
}
}
public class Solution {
public static void main(String[] args) throws IOException {
BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(System.in));
List<Integer> arr = Stream.of(bufferedReader.readLine().replaceAll("\\s+$", "").split(" "))
.map(Integer::parseInt)
.collect(Collectors.toList());
Result.miniMaxSum(arr);
bufferedReader.close();
}
}