483 {
484 int n;
485 cin >> n;
486 auto *above = new bool[n];
487 auto heights = set<unsigned int>();
488 auto m = map<unsigned int, vector<unsigned int>>();
489 for(int i = 0; i < n; i++) {
490 int height;
491 cin >> height;
492 heights.insert(height);
493 above[i] = true;
494 if(!m.contains(height)) {
495 m[height] = vector<unsigned int>();
496 }
497 m[height].push_back(i);
498 }
499 int count = 1;
500 int max = count;
501 for(auto height: heights) {
502 for(const auto index: m[height]) {
503 above[index] = false;
504 if(0 < index && index + 1 < n) {
505 if(above[index - 1] && above[index + 1]) {
506 count++;
507 } else if(!above[index - 1] && !above[index + 1]) {
508 count--;
509 }
510 } else if(index == 0 && !above[1] || index == n - 1 && !above[n - 2]) {
511 count--;
512 }
513 }
514 if(max < count) {
515 max = count;
516 }
517 }
518 cout << max;
519 delete[] above;
520 return 0;
521 }