func_code_string: #include <bits/stdc++.h>   using namespace std;   int main() {     int n;     cin >> n;     int a[n];     for (int i = 0; i < n; i++) {       cin >> a[i];     }     vector<int> records;     int max = a[0];     records.push_back(0);     int case1 = -1;     int case1_records;     for (int i = 1; i < n; i++) {       if (max < a[i]) {         max = a[i];         records.push_back(i);       } else {         if (case1 == -1) {           case1 = i;         } else {           if (a[case1] > a[i]) {             case1 = i;           }         }       }     }     case1_records = records.size();     records.push_back(n);     int case2 = -1;     int case2_records = -1;     int case2_pos = -1;     for (int i = 0; i < records.size() - 1; i++) {       int left = records[i];       int right = records[i + 1];       int count = 0;       int max = 0;       if (i > 0) {         left = records[i - 1];         max = a[records[i - 1]];       }       for (int j = left + 1; j < right; j++) {         if (j != records[i])           if (max < a[j]) {             max = a[j];             count++;           }       }       if (case2 < count) {         case2 = count;         case2_pos = records[i];       }     }     case2_records = case1_records - 1 + case2;     if (case1 == -1) {       cout << a[case2_pos] << endl;     } else {       if (case1_records < case2_records) {         cout << a[case2_pos] << endl;       } else if (case1_records == case2_records) {         cout << min(a[case1], a[case2_pos]) << endl;       } else {         cout << a[case1] << endl;       }     }     return 0;   }   