Language: C++

#include<bits/stdc++.h>
using namespace std;
long long left=2,right=2;
int n,ans[100010];
int main()
{
	cin>>n;
	for(int i=1; i<=n; i++)
	{
		cin>>ans[i];
	}
	for(int i=n; i>=1; i--)
	{
		left=((left-1)/ans[i]+1)*ans[i];
		right=right/ans[i]*ans[i]+ans[i]-1;
	}
	if(left>right)cout<<-1;
	else cout<<left<<" "<<right;
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:14:17: error: reference to 'left' is ambiguous
   14 |                 left=((left-1)/ans[i]+1)*ans[i];
      |                 ^~~~
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:3:11: note:                 'long long int left'
    3 | long long left=2,right=2;
      |           ^~~~
a.cc:14:24: error: reference to 'left' is ambiguous
   14 |                 left=((left-1)/ans[i]+1)*ans[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:3:11: note:                 'long long int left'
    3 | long long left=2,right=2;
      |           ^~~~
a.cc:15:17: error: reference to 'right' is ambiguous
   15 |                 right=right/ans[i]*ans[i]+ans[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:3:18: note:                 'long long int right'
    3 | long long left=2,right=2;
      |                  ^~~~~
a.cc:15:23: error: reference to 'right' is ambiguous
   15 |                 right=right/ans[i]*ans[i]+ans[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:3:18: note:                 'long long int right'
    3 | long long left=2,right=2;
      |                  ^~~~~
a.cc:17:12: error: reference to 'left' is ambiguous
   17 |         if(left>right)cout<<-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:3:11: note:                 'long long int left'
    3 | long long left=2,right=2;
      |           ^~~~
a.cc:17:17: error: reference to 'right' is ambiguous
   17 |         if(left>right)cout<<-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:3:18: note:                 'long long int right'
    3 | long long left=2,right=2;
      |                  ^~~~~
a.cc:18:20: error: reference to 'left' is ambiguous
   18 |         else cout<<left<<" "<<right;
      |                    ^~~~
/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:3:11: note:                 'long long int left'
    3 | long long left=2,right=2;
      |           ^~~~
a.cc:18:31: error: reference to 'right' is ambiguous
   18 |         else cout<<left<<" "<<right;
      |                               ^~~~~
/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:3:18: note:                 'long long int right'
    3 | long long left=2,right=2;
      |                  ^~~~~