import java.util.ArrayList; import java.util.Collections; import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int N = sc.nextInt(); sc.nextLine(); ArrayList list = new ArrayList(); for (int i = 0; i < N; i++) { String s = sc.nextLine(); String str[] = s.split(" "); for (int j = 0; j < str.length; j++) { list.add(Integer.parseInt(str[j])); } } Collections.sort(list); int m = 0, n = 0; for (int i = 0; i < list.size() - 1; i++) { if (list.get(i) + 2 == list.get(i + 1)) m = list.get(i) + 1; if (list.get(i).equals(list.get(i + 1))) n = list.get(i); } System.out.println(m + " " + n); } }