#include #include using namespace std; int main(){ int n; cin >> n; vector types(n); for(int types_i = 0; types_i < n; types_i++){ cin >> types[types_i]; } // your code goes here int a[5]={0},pre_index=0,index=0,maxm=0; for(int i=0; i a[types[i]-1] ? pre_index : (maxm == a[types[i]-1] ? ( pre_index > types[i] ? types[i] : pre_index ) : types[i] ) ; pre_index = index; maxm= max(maxm,a[types[i]-1]); } cout << index ; return 0; }