Language: C++

#include <bits/stdc++.h>
using namespace std;

int n, a[200004], left[200004], right[200004];

int main() {
	cin>>n;
	for(int i = 1;i<=n;i++)	cin>>a[i];
	left[0] = 0;
	// left[i] : maximum of a[1], a[2], ..., a[i]
	for(int i = 1;i<=n;i++)	left[i] = max(left[i-1], a[i]);
	
	// right[i] : maximum of a[i], a[i+1], ..., a[n]
	right[n+1] = 0;
	for(int i = n; i>=1; i--)	right[i] = max(right[i+1], a[i]);
	
	for(int i = 1;i<=n;i++)
		cout<<max(left[i-1], right[i+1])
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:9:9: error: reference to 'left' is ambiguous
    9 |         left[0] = 0;
      |         ^~~~
In file included from /usr/include/c++/14/streambuf:43,
                 from /usr/include/c++/14/bits/streambuf_iterator.h:35,
                 from /usr/include/c++/14/iterator:66,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:54,
                 from a.cc:1:
/usr/include/c++/14/bits/ios_base.h:1062:3: note: candidates are: 'std::ios_base& std::left(ios_base&)'
 1062 |   left(ios_base& __base)
      |   ^~~~
a.cc:4:19: note:                 'int left [200004]'
    4 | int n, a[200004], left[200004], right[200004];
      |                   ^~~~
a.cc:11:33: error: reference to 'left' is ambiguous
   11 |         for(int i = 1;i<=n;i++) left[i] = max(left[i-1], a[i]);
      |                                 ^~~~
/usr/include/c++/14/bits/ios_base.h:1062:3: note: candidates are: 'std::ios_base& std::left(ios_base&)'
 1062 |   left(ios_base& __base)
      |   ^~~~
a.cc:4:19: note:                 'int left [200004]'
    4 | int n, a[200004], left[200004], right[200004];
      |                   ^~~~
a.cc:11:47: error: reference to 'left' is ambiguous
   11 |         for(int i = 1;i<=n;i++) left[i] = max(left[i-1], a[i]);
      |                                               ^~~~
/usr/include/c++/14/bits/ios_base.h:1062:3: note: candidates are: 'std::ios_base& std::left(ios_base&)'
 1062 |   left(ios_base& __base)
      |   ^~~~
a.cc:4:19: note:                 'int left [200004]'
    4 | int n, a[200004], left[200004], right[200004];
      |                   ^~~~
a.cc:14:9: error: reference to 'right' is ambiguous
   14 |         right[n+1] = 0;
      |         ^~~~~
/usr/include/c++/14/bits/ios_base.h:1070:3: note: candidates are: 'std::ios_base& std::right(ios_base&)'
 1070 |   right(ios_base& __base)
      |   ^~~~~
a.cc:4:33: note:                 'int right [200004]'
    4 | int n, a[200004], left[200004], right[200004];
      |                                 ^~~~~
a.cc:15:41: error: reference to 'right' is ambiguous
   15 |         for(int i = n; i>=1; i--)       right[i] = max(right[i+1], a[i]);
      |                                         ^~~~~
/usr/include/c++/14/bits/ios_base.h:1070:3: note: candidates are: 'std::ios_base& std::right(ios_base&)'
 1070 |   right(ios_base& __base)
      |   ^~~~~
a.cc:4:33: note:                 'int right [200004]'
    4 | int n, a[200004], left[200004], right[200004];
      |                                 ^~~~~
a.cc:15:56: error: reference to 'right' is ambiguous
   15 |         for(int i = n; i>=1; i--)       right[i] = max(right[i+1], a[i]);
      |                                                        ^~~~~
/usr/include/c++/14/bits/ios_base.h:1070:3: note: candidates are: 'std::ios_base& std::right(ios_base&)'
 1070 |   right(ios_base& __base)
      |   ^~~~~
a.cc:4:33: note:                 'int right [200004]'
    4 | int n, a[200004], left[200004], right[200004];
      |                                 ^~~~~
a.cc:18:27: error: reference to 'left' is ambiguous
   18 |                 cout<<max(left[i-1], right[i+1])
      |                           ^~~~
/usr/include/c++/14/bits/ios_base.h:1062:3: note: candidates are: 'std::ios_base& std::left(ios_base&)'
 1062 |   left(ios_base& __base)
      |   ^~~~
a.cc:4:19: note:                 'int left [200004]'
    4 | int n, a[200004], left[200004], right[200004];
      |                   ^~~~
a.cc:18:38: error: reference to 'right' is ambiguous
   18 |                 cout<<max(left[i-1], right[i+1])
      |                                      ^~~~~
/usr/include/c++/14/bits/ios_base.h:1070:3: note: candidates are: 'std::ios_base& std::right(ios_base&)'
 1070 |   right(ios_base& __base)
      |   ^~~~~
a.cc:4:33: note:                 'int right [200004]'
    4 | int n, a[200004], left[200004], right[200004];
      |                                 ^~~~~