import java.io.*; import java.util.*; import java.text.*; import java.math.*; import java.util.regex.*; public class Solution { public static void main(String[] args) { Scanner s = new Scanner(System.in); int[] types = new int[5]; int maxType = 0; int max = 0; int birds = s.nextInt(); for (int i = 0; i < birds; i++) { int t = s.nextInt(); ++types[t-1]; if (types[t-1] == max) { if (t < maxType) { maxType = t; } } else if (types[t-1] > max) { maxType = t; max = types[t-1]; } } System.out.println(maxType); } }