import java.util.*; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = Integer.parseInt(sc.nextLine()); ArrayList numbers = new ArrayList<>(); ArrayList chars = new ArrayList<>(); char[] arr = sc.nextLine().toCharArray(); for (int i = 0; i < arr.length; i += 2) { if (arr[i] >= '0' && arr[i] <= '9') { numbers.add(arr[i] - '0'); } else { chars.add(arr[i]); } } Collections.sort(numbers); Collections.sort(chars); long max = 0; int count = numbers.size() - chars.size(); for (int i = 0; i < count; i++) { max *= 10; max += numbers.get(numbers.size() - 1 - i); } long min; if (chars.get(chars.size() - 1) == '-') { min = - max; for (int i = chars.size() - 2; i >= 0; i--) { if (chars.get(i) == '+') { min += numbers.get(i + 1); } else { min -= numbers.get(i + 1); } } min += numbers.get(0); } else { int[] values = new int[chars.size() + 1]; for (int i = 0; i < numbers.size(); i++) { int idx = i % values.length; values[idx] *= 10; values[idx] += numbers.get(i); } min = 0; for (int i = 0; i < values.length; i++) { min += values[i]; } } for (int i = 0; i < chars.size(); i++) { if (chars.get(chars.size() - 1 - i) == '+') { max += numbers.get(i); } else { max -= numbers.get(i); } } System.out.println(max + " " + min); } }