#include <bits/stdc++.h>   using namespace std;   struct like {     int id;     int change = 0;   };   int main() {     int n, s, max = 0, idmax = 0, count = 0, k = 0;     cin >> n;     like *A = new like[n];     for (int i = 0; i < n; i++) {       cin >> s;       k = 1;       for (int j = 0; j < count; j++) {         if (A[j].id == s) {           A[j].change++;           k = 0;           if (A[j].change > max) {             max = A[j].change;             idmax = A[j].id;           }         }       }       if (k == 1) {         A[count].id = s;         A[count].change++;         if (A[count].change > max) {           max = A[count].change;           idmax = A[count].id;         }         count++;       }     }     cout << idmax << endl;     return 0;   }   