✅코드
import java.io.*;
import java.util.*;
public class Main {
public static void main(String[] args) throws Exception {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));
int n = Integer.parseInt(br.readLine());
long[] nums = new long[n];
for (int i = 0; i < n; i++) {
nums[i] = Long.parseLong(br.readLine());
}
Arrays.sort(nums);
int maxCnt = 1, cnt = 1;
long maxNum = nums[0];
for (int i = 1; i < n; i++) {
if (nums[i] == nums[i - 1]) {
cnt++;
} else {
cnt = 1;
}
if (cnt > maxCnt) {
maxCnt = cnt;
maxNum = nums[i];
}
}
bw.write(Long.toString(maxNum));
bw.newLine();
bw.flush();
br.close();
bw.close();
}
}