import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.HashMap; import java.util.Map; public class No00000079_Main { public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); br.readLine(); System.out.println(getLevel(getCnt(br.readLine().split(" ")))); } private static Map getCnt(String[] strArr) { Map ret = new HashMap(); for(String s : strArr) { if(ret.containsKey(s)) { ret.put(s, ret.get(s) + 1); } else { ret.put(s, 1); } } return ret; } private static String getLevel(Map aMap) { String retLevel = ""; int retCnt = 0; for(Map.Entry ent : aMap.entrySet()) { if(retCnt < ent.getValue() || (retCnt == ent.getValue() && retLevel.compareTo(ent.getKey()) < 0)) { retLevel = ent.getKey(); retCnt = ent.getValue(); } } return retLevel; } }