import java.io.*; import java.util.*; import java.text.*; import java.math.*; import java.util.regex.*; public class Solution implements Comparable { int type = 0; int count = 0; public int compareTo(Solution bird) { if (this.type < bird.type) { return -1; } else if (this.type == bird.type) { return 0; } else { return 1; } } @Override public boolean equals(Object o) { if (this == o) return true; if (!(o instanceof Solution)) return false; Solution bird = (Solution) o; return type == bird.type; } @Override public int hashCode() { return type; } public static void main(String[] args) { Scanner in = new Scanner(System.in); int n = in.nextInt(); List birdL = new ArrayList(); boolean allSame = true; int maxCount = 1; for (int types_i = 0; types_i < n; types_i++) { Solution bird = new Solution(); bird.count = 1; bird.type = in.nextInt(); if (birdL.contains(bird)) { Solution b = birdL.get(birdL.indexOf(bird)); b.count = b.count + 1; birdL.set(birdL.indexOf(bird), b); if(b.count > maxCount){ maxCount=b.count; } allSame = false; } else { birdL.add(bird); } } Collections.sort(birdL); if(allSame) { System.out.println(birdL.get(0).type); }else{ for(Solution b:birdL){ if(b.count==maxCount){ System.out.println(b.type); break; } } } } }