#include <iostream> #include <windows.h> using namespace std; typedef struct letter{ int data; int count; } letter; int main() { int *p,num,i; letter *count; cin>>num; p = new int[num]; count = new letter[num]; for(i = 0;i < num; i++) cin>>p[i]; for(i = 0;i < num; i++) count[i].count = 0; for(i = 0;i < num; i++) cout<<p[i]<<" "; int pos = 0; for(int l = 0;l < num; l++) { bool flag = false; for(int k = 0;k < pos; k++) if(l==0) { count[pos].count++; count[pos].data = p[l]; pos++; } else { if(p[l]==count[k].data) { count[k].count++; flag = true; } } if(flag==false) { count[pos].data = p[l]; count[pos].count++; pos++; } } for(l = 0;l < pos-1; l++) for(int k = 0;k < pos-l-1; k++) if(count[k].count<count[k+1].count) { letter temp; temp.count = count[k].count; temp.data = count[k].data; count[k].count = count[k+1].count; count[k].data = count[k+1].data; count[k+1].count = temp.count; count[k+1].data = temp.data; } int times = 0; if(count[0].count==count[1].count) { for(int k = 0;k < pos; k++) if(count[k].count==count[k+1].count) { times++; break; } int min = 1000000000; for(k = 0;k <= times; k++) if(count[k].data<min) min = count[k].data; cout<<min<<endl; } else cout<<count[0].data<<endl; /*for(int k = 0;k < pos; k++) cout<<"letter: "<<count[k].data<<" num: "<<count[k].count<<endl; system("pause"); cout<<endl;*/ return 0; }