stablegradients/pie-gem5-bysrc huggingface dataset:
// Original C++ solution (slower):
#include <iostream>

#include <vector>

using namespace std;

typedef long long ll;



inline ll ceiling(ll a, ll m) { return (a + m - 1) / m; }



int main() {

  int k;

  cin >> k;

  vector<ll> a(k + 1);

  for (int i = 1; i <= k; i++) {

    cin >> a[i];

  }

  ll mn = 2;

  ll mx = 2;

  for (int i = k; i > 0; i--) {

    // [L, R]のaの倍数のminは、ceil(L/a)*a

    //                  maxは、floar(R/a)*a

    ll amn = ceiling(mn, a[i]) * a[i];

    ll amx = mx / a[i] * a[i];

    if (amn > mx || amx < mn) {

      cout << -1 << endl;

      return 0;

    }

    mn = amn;

    mx = amx + a[i] - 1;

  }

  cout << mn << " " << mx << endl;

}


// Optimized solution to the same problem (faster):
#include <stdio.h>

typedef long long ll;



int main() {

  int k;

  scanf("%d", &k);

  ll a[100005];

  for (int i = 0; i < k; i++) {

    scanf("%lld", &a[i]);

  }

  ll mn = 2;

  ll mx = 2;

  for (int i = k - 1; i >= 0; i--) {

    // [L, R]のaの倍数のminは、ceil(L/a)*a

    //                  maxは、floar(R/a)*a

    ll amn = (mn + a[i] - 1) / a[i] * a[i];

    ll amx = mx / a[i] * a[i];

    if (amn > mx) {

      printf("%d", -1);

      return 0;

    }

    mn = amn;

    mx = amx + a[i] - 1;

  }

  printf("%lld %lld", mn, mx);

}


// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <iostream>

using namespace std;

typedef long long ll;



int main() {

  int k;

  cin >> k;

  ll a[100005];

  for (int i = 0; i < k; i++) {

    cin >> a[i];

  }

  ll mn = 2;

  ll mx = 2;

  for (int i = k - 1; i >= 0; i--) {

    // [L, R]のaの倍数のminは、ceil(L/a)*a

    //                  maxは、floar(R/a)*a

    ll amn = (mn + a[i] - 1) / a[i] * a[i];

    ll amx = mx / a[i] * a[i];

    if (amn > mx) {

      cout << -1 << endl;

      return 0;

    }

    mn = amn;

    mx = amx + a[i] - 1;

  }

  cout << mn << " " << mx << endl;

}


// Optimized solution to the same problem (faster):
#include <stdio.h>

typedef long long ll;



int main() {

  int k;

  scanf("%d", &k);

  ll a[100005];

  for (int i = 0; i < k; i++) {

    scanf("%lld", &a[i]);

  }

  ll mn = 2;

  ll mx = 2;

  for (int i = k - 1; i >= 0; i--) {

    // [L, R]のaの倍数のminは、ceil(L/a)*a

    //                  maxは、floar(R/a)*a

    ll amn = (mn + a[i] - 1) / a[i] * a[i];

    ll amx = mx / a[i] * a[i];

    if (amn > mx) {

      printf("%d", -1);

      return 0;

    }

    mn = amn;

    mx = amx + a[i] - 1;

  }

  printf("%lld %lld", mn, mx);

}


// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<bits/stdc++.h>

#define i64 long long

#define inf 1000000000000000000

using namespace std;

i64 ara[100009];





i64 n;

i64 f(i64 mid)

{

    for(i64 i=0; i<n; i++)

    {

        mid= (mid/ara[i])*ara[i];

        //printf("%d / %lld *%d\n",mid,ara[i],ara[i]);



    }



    return mid;



}





int main()



{





    scanf("%lld",&n);

    for(i64 i=0; i<n; i++)

        scanf("%lld",&ara[i]);









    i64 lo=1,hi=1000000000000000000,cnt=0,mid,res1,res2;





    while(cnt++<70)

    {

        mid=(lo+hi)/2;



        if(f(mid)>=2)

            hi=mid;

        else lo=mid;



    }



    if(f(mid)<2) mid++;





    if(f(mid)!=2)

    {

        res1=-1;

    }

    else res1=mid;





    lo=1,hi=1000000000000000000,cnt=0,mid=0;





    while(cnt++<70)

    {

        mid=(lo+hi)/2;



        if(f(mid)>2)

            hi=mid;

        else lo=mid;



    }



    if(f(mid)<2) mid++;



    if(f(mid)!=2)

    {

        res2=-1;

    }

    else

        res2=mid;





    if(res1==-1 || res2==-1)

        printf("-1\n");

    else

        printf("%lld %lld\n",res1,res2);





}


// Optimized solution to the same problem (faster):
#include<cstdio>

#include<cstring>

#include<algorithm>

#define ll long long

#define MN 100005

using namespace std;

inline ll in(){

    ll x=0;bool f=0; char c;

    for (;(c=getchar())<'0'||c>'9';f=c=='-');

    for (x=c-'0';(c=getchar())>='0'&&c<='9';x=(x<<3)+(x<<1)+c-'0');

    return f?-x:x;

}

ll a[MN],n,mx,mn,x,y;

int main()

{

	n=in();

	for (int i=1;i<=n;++i) a[i]=in();a[n+1]=2ll;mn=mx=2ll;

	for (int i=n;i;--i){

		mx/=a[i];if (!mx) {printf("-1");return 0;}

		mx=(mx+1ll)*a[i]-1ll;

		if (mn%a[i]) mn=(mn/a[i]+1ll)*a[i];

	}x=mx,y=mn;

	for (int i=1;i<=n;++i){

		x-=(x%a[i]);y-=(y%a[i]);

	}if (x!=2||y!=2) {printf("-1");return 0;}

	printf("%lld %lld",mn,mx);return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<iostream>

using namespace std;

int main(){

    int A[100010],n,i,ans=1;

    cin>>n;

    for(i=1;i<=n;i++) cin>>A[i];

    long long min=2,max=2;

    for(i=n;i>=1;i--){

        max=A[i]*(max/A[i]);

        max=max+A[i]-1;

        min=A[i]*((min-1)/A[i]+1);

        if(max<min){

            ans=0;

            break;

        }

    }

    if(ans==0) cout<<-1<<endl;

    else cout<<min<<" "<<max<<endl;

    return 0;

}




// Optimized solution to the same problem (faster):
#include<cstdio>

#include<cstring>

#include<algorithm>

#define ll long long

#define MN 100005

using namespace std;

inline ll in(){

    ll x=0;bool f=0; char c;

    for (;(c=getchar())<'0'||c>'9';f=c=='-');

    for (x=c-'0';(c=getchar())>='0'&&c<='9';x=(x<<3)+(x<<1)+c-'0');

    return f?-x:x;

}

ll a[MN],n,mx,mn,x,y;

int main()

{

	n=in();

	for (int i=1;i<=n;++i) a[i]=in();a[n+1]=2ll;mn=mx=2ll;

	for (int i=n;i;--i){

		mx/=a[i];if (!mx) {printf("-1");return 0;}

		mx=(mx+1ll)*a[i]-1ll;

		if (mn%a[i]) mn=(mn/a[i]+1ll)*a[i];

	}x=mx,y=mn;

	for (int i=1;i<=n;++i){

		x-=(x%a[i]);y-=(y%a[i]);

	}if (x!=2||y!=2) {printf("-1");return 0;}

	printf("%lld %lld",mn,mx);return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <cstdio>

#include <cstring>

#include <iostream>

#include <string>

#include <algorithm>

#include <set>

#include <map>

#include <vector>

#include <cstring>

using namespace std;

typedef long long LL;

const int MAXN = 100005;

LL a[MAXN];

int n;

LL judge(LL x)

{

    for(int i=1;i<=n;++i)

        x=x/a[i]*a[i];

    return x;

}

int main()

{

    scanf("%d", &n);

    for(int i=1;i<=n;++i)

        scanf("%lld", &a[i]);

    LL l=2, r=1e15;

    LL mid;

    LL Max=-1, Min=-1;

    while(l<=r)

    {

        mid=(l+r)>>1;

        if(judge(mid)>=2)

            r=mid-1, Min=mid;

        else

            l=mid+1;

    }

    l=2,r=1e15;

    while(l<=r)

    {

        mid=(l+r)>>1;

        if(judge(mid)>2)

            r=mid-1;

        else

            l=mid+1, Max=mid;

    }

    if(judge(Min)!=2||judge(Max)!=2)

        puts("-1");

    else

        printf("%lld %lld\n", Min, Max);

    return 0;

}

// Optimized solution to the same problem (faster):
/*令L(i),R(i)表示第i轮过后的最小人数和最大人数。



令X(i)和Y(i)表示区间[L(i),R(i)]中最小的a[i]倍数和最大的a[i]倍数。



L(i-1)=X(i)，R(i-1)=Y(i)+a[i]-1。



X(i)=L(i)/a[i]（上取整），Y(i)=R(i)/a[i]（下取整）。



答案为L(0),R(0)。*/

#include<cstdio>

int n,a[100010];

long long L=2,R=2;

int main(){

    scanf("%d",&n);

    for(int i=1;i<=n;i++)scanf("%d",&a[i]);

    for(int i=n;i>=1;i--){

        L=((L-1)/a[i]+1)*a[i];

        R=R/a[i]*a[i]+a[i]-1;

    }

    if(L>R)printf("-1");

    else printf("%lld %lld",L,R);

    return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;



int n;

ll ara[100000 + 5];



ll check(ll k) {

    for(int i = 0; i < n; i++)

        k -= k % ara[i];

    return k;

}



int main() {

    cin >> n;

    for(int i = 0; i < n; i++) 

        cin >> ara[i];

    ll lo = 0, hi = 100000000000000, ans = -1;

    while(lo <= hi) {

        ll mid = (lo + hi) / 2;

        ll k = check(mid);

        if(k == 2) {

            ans = mid;

            hi = mid - 1;

        }

        else if(k > 2)

            hi = mid - 1;

        else

            lo = mid + 1;

    }

    

    if(ans != -1)

        cout << ans << " ";

    else {

        cout << -1 << endl;

        return 0;

    }

    

    lo = 0, hi = 100000000000000, ans = -1;

    while(lo <= hi) {

        ll mid = (lo + hi) / 2;

        ll k = check(mid);

        if(k == 2) {

            ans = mid;

            lo = mid + 1;

        }

        else if(k > 2)

            hi = mid - 1;

        else

            lo = mid + 1;

    }

    

    if(ans != -1)

        cout << ans << " ";

    else {

        cout << -1 << endl;

        return 0;

    }

    return 0;

}

// Optimized solution to the same problem (faster):
#include<cstdio>

int k,a[100005];

long long maxn=2,minn=2;

int main(){

	scanf("%d",&k);

	for(int i=1;i<=k;++i) scanf("%d",&a[i]);

	for(int i=k;i>=1&&maxn>=minn;--i){

		if(minn%a[i]) minn=minn/a[i]*a[i]+a[i];

		maxn=(maxn/a[i]+1)*a[i]-1;

	}

	if(maxn>=minn) printf("%lld %lld\n",minn,maxn);

	else puts("-1");

	return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<bits/stdc++.h>

using namespace std;

#define loop(i,L,R) for(int i=(L);i<=(R);i++)

#define rept(i,L,R) for(int i=(L);i<(R);i++)

#define isc(n) scanf("%d",&n)

#define llsc(n) scanf("%lld",&n)

#define dsc(n) scanf("%lf",&n)

#define enl cout<<endl

#define pb(x) push_back(x)

#define xx first

#define yy second

typedef long long ll;

typedef pair<int,int>PI;

typedef pair<pair<int,int>,int>PII;

const int mx=1e5+10;

ll dhuko[mx][2],bahir[mx][2];

ll arr[mx];

int main()

{

	int n;

	cin>>n;

	loop(i,1,n)cin>>arr[i];

	int flag=0;

	dhuko[n+1][0]=2;

	dhuko[n+1][1]=2;

	for(int i=n;i>0;i--)

	{

       // cout<<dhuko[i+1][0]<<" "<<dhuko[i+1][1]<<endl;

        bahir[i][0]=(dhuko[i+1][0]/arr[i])*arr[i];

        if(bahir[i][0]<dhuko[i+1][0])bahir[i][0]+=arr[i];

        bahir[i][1]=(dhuko[i+1][1]/arr[i])*arr[i];

        //cout<<i<<" "<<bahir[i][0]<<" "<<bahir[i][1]<<endl;

        if(bahir[i][0]>dhuko[i+1][1] && bahir[i][1]<dhuko[i+1][0])

        {

            flag=1;

            break;

        }

        if(bahir[i][0]>dhuko[i+1][1])bahir[i][0]=bahir[i][1];

        else if(bahir[i][1]<dhuko[i+1][0])bahir[i][1]=bahir[i][0];



        //cout<<i<<" "<<bahir[i][0]<<" "<<bahir[i][1]<<endl;

        dhuko[i][0]=bahir[i][0];

        dhuko[i][1]=bahir[i][1]+arr[i]-1;

	}

	if(flag)cout<<-1<<endl;

	else cout<<dhuko[1][0]<<" "<<dhuko[1][1]<<endl;

	return 0;

}


// Optimized solution to the same problem (faster):
#include<cstdio>

int k,a[100005];

long long maxn=2,minn=2;

int main(){

	scanf("%d",&k);

	for(int i=1;i<=k;++i) scanf("%d",&a[i]);

	for(int i=k;i>=1&&maxn>=minn;--i){

		if(minn%a[i]) minn=minn/a[i]*a[i]+a[i];

		maxn=(maxn/a[i]+1)*a[i]-1;

	}

	if(maxn>=minn) printf("%lld %lld\n",minn,maxn);

	else puts("-1");

	return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;



const int maxi = 111111;

int a[maxi], k;



ll rem(ll val) {

    for(int i=1; i<=k; i++) {

        if(val % a[i] == 0) continue;

        else val -= val % a[i];

    }

    return val;

}



ll solveMax() {

    ll lo = 0, hi = 1e14, res = -1;

    int cnt = 60;



    while(cnt--) {

        ll mid = (lo + hi) / 2;

        if(rem(mid) == 2) res = mid;

        if(rem(mid) <= 2) lo = mid;

        else hi = mid;

    }



    return res;

}



ll solveMin() {

    ll lo = 0, hi = 1e14, res = -1;

    int cnt = 60;



    while(cnt--) {

        ll mid = (lo + hi) / 2;

        if(rem(mid) == 2) res = mid;

        if(rem(mid) < 2) lo = mid;

        else hi = mid;

    }



    return res;

}



int main() {

    cin>>k;



    for(int i=1; i <= k; i++) {

        cin>>a[i];

    }



    ll mx = solveMax(), mn = solveMin();



    if(mx == -1 || mn == -1) cout<<-1<<endl;

    else cout<<mn<<" "<<mx<<endl;

    return 0;

}


// Optimized solution to the same problem (faster):
#include<cstdio>

int k,a[100005];

long long maxn=2,minn=2;

int main(){

	scanf("%d",&k);

	for(int i=1;i<=k;++i) scanf("%d",&a[i]);

	for(int i=k;i>=1&&maxn>=minn;--i){

		if(minn%a[i]) minn=minn/a[i]*a[i]+a[i];

		maxn=(maxn/a[i]+1)*a[i]-1;

	}

	if(maxn>=minn) printf("%lld %lld\n",minn,maxn);

	else puts("-1");

	return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;



const int sz = 100005;

long long a[sz];

long long k;

const long long inf = 1000000000000000000LL;



int f(int n)

{



    cout<<n<<": ";

    for(int i = 1; i<=k; i++)

    {



        int x = n%a[i];

        n-=x;

    }



    cout<<n<<endl;

    if(n==2) return 1;

    return 0;



}



long long foo(long long n)

{



    for(int i = 1; i<=k; i++)

    {



        int x = n%a[i];

        n-=x;

    }

    return n;

}





int main()

{



    scanf("%lld", &k);



    for(int i = 1; i<=k; i++) scanf("%lld", &a[i]);





    // finding upper bound;



    long long lo = 1, hi = 1e18, mid, top = -1, lolo = inf;



    for(int j = 0; j<100; j++)

    {



        mid = (hi+lo)/2;



        long long x = foo(mid);



        if(x==2)

        {



            top = max(top, mid);

            lo = mid+1;

        }

        else if(x<2)

        {

            lo = mid+1;

        }



        else hi = mid;



    }



    lo = 1;

    hi = 1e18;

    for(int j = 0; j<100; j++)

    {



        mid = (hi+lo)/2;



        long long x = foo(mid);



        if(x==2)

        {



            lolo = min(lolo, mid);

            hi = mid;

        }

        else if(x<2)

        {

            lo = mid+1;

        }



        else hi = mid;



    }



    if(top == -1) cout<<-1<<endl;



    else cout<<lolo<<" "<<top<<endl;





}


// Optimized solution to the same problem (faster):
#include<cstdio>

int k,a[100005];

long long maxn=2,minn=2;

int main(){

	scanf("%d",&k);

	for(int i=1;i<=k;++i) scanf("%d",&a[i]);

	for(int i=k;i>=1&&maxn>=minn;--i){

		if(minn%a[i]) minn=minn/a[i]*a[i]+a[i];

		maxn=(maxn/a[i]+1)*a[i]-1;

	}

	if(maxn>=minn) printf("%lld %lld\n",minn,maxn);

	else puts("-1");

	return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<iostream>

#include<cstdio>

#include<cstdlib>

#include<cstring>

#include<algorithm>

#include<cmath>

#define ll long long

using namespace std;

ll a[100010];

ll ansmx,ansmi;

int n;

int main(){

	scanf("%d",&n);

	int i,j;

	for(i=1;i<=n;++i){

		scanf("%lld",&a[i]);

	}

	ansmx=ansmi=2;

	for(i=n;i>=1;--i){

		ansmx=(ansmx/a[i]+1)*a[i]-1;

		if(ansmi%a[i]!=0){

			ansmi=ansmi/a[i];

			ansmi=ansmi*a[i]+a[i];

		}

	}

	if(ansmx>=ansmi){

		printf("%lld %lld\n",ansmi,ansmx);

	}

	else  printf("-1\n");

	return 0;

}

// Optimized solution to the same problem (faster):
#include<cstdio>

int k,a[100005];

long long maxn=2,minn=2;

int main(){

	scanf("%d",&k);

	for(int i=1;i<=k;++i) scanf("%d",&a[i]);

	for(int i=k;i>=1&&maxn>=minn;--i){

		if(minn%a[i]) minn=minn/a[i]*a[i]+a[i];

		maxn=(maxn/a[i]+1)*a[i]-1;

	}

	if(maxn>=minn) printf("%lld %lld\n",minn,maxn);

	else puts("-1");

	return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>

#include <sstream>

#include <iomanip>

#include <cstdio>

#include <cstdlib>

#include <cmath>

#include <cctype>

#include <cstring>

#include <vector>

#include <list>

#include <queue>

#include <deque>

#include <stack>

#include <map>

#include <set>

#include <algorithm>

#include <iterator>

#include <bitset>

#include <ctime>

#include<complex>

#include<unordered_set>

using namespace std;



#define FOR(i,a,b) for(int i = (a); i < (b); i++)

#define RFOR(i,b,a) for(int i = (b) - 1; i >= (a); i--)

#define ITER(it, a) for(typeof(a.begin()) it = a.begin(); it != a.end(); it++)

#define FILL(a, value) memset(a, value, sizeof(a))



#define SZ(a) (int) a.size()

#define ALL(a) a.begin(),a.end()

#define PB push_back

#define MP make_pair



typedef long long LL;

typedef vector<int> VI;

typedef pair<int, int> PII;



const double PI = acos(-1.0);

const LL INF = 1000 * 1000 * 1000 + 7;

const LL LINF = INF * (LL)INF;



const int MAX = 100 * 1000 + 47;



LL A[MAX];



void no()

{

	cout << -1 << endl;

	exit(0);

}



int main()

{

	//freopen("in.txt", "r", stdin);

	//freopen("out.txt", "w", stdout);

	//ios::sync_with_stdio(false); cin.tie(0);

	int n;

	cin >> n;

	A[0] = 1;

	FOR(i, 1, n + 1) cin >> A[i];

	LL k = 2;

	if (A[n] != 2) no();



	LL a = 2;

	LL b = 2;



	RFOR(i, n + 1, 1)

	{

		b = b + A[i] - 1;

		a = ((a + A[i - 1] - 1) / A[i - 1]) * A[i - 1];

		b = (b / A[i - 1]) * A[i - 1];

		if (a > b) no();

	}



	cout << a << " " << b << endl;

}

// Optimized solution to the same problem (faster):
#include<stdio.h>

int x[100005];

int main()

{

	int k,i;long long max=2,min=2;

	scanf("%d",&k);

	for(i=0;i<k;i++)

	{

		scanf("%d",&x[i]);

	}

	for(i=k-1;i>=0;i--)

	{

		if(min%x[i]!=0) min=min/x[i]*x[i]+x[i];

		max=max/x[i]*x[i]+x[i]-1;

		if(max<min)break;

	}

	if(max>=min) printf("%lld %lld\n",min,max);

	else printf("-1\n");

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <bits/stdc++.h>

using namespace std;



using ll = long long;



#define REP(i, n) for (int i = 0; i < (n); ++i)

#define SIZE(a) ((int)(a).size())



const int N = 100005;

const ll linf = 2e18;



int n, a[N];



int main() {

	ios::sync_with_stdio(false);

	cin.tie(0);



	cin >> n;

	REP(i, n) cin >> a[i];

	reverse(a, a + n);

	ll l, r;

	l = r = 2;

	REP(i, n) {

		ll nl = l % a[i] ? l + a[i] - l % a[i] : l;

		ll nr = r - r % a[i] + a[i] - 1;

		if (nl > nr) {

			cout << -1 << '\n';

			return 0;

		}

		l = nl;

		r = nr;

	}



	cout << l << ' ' << r << '\n';



	return 0;

}

// Optimized solution to the same problem (faster):
#include<stdio.h>

int x[100005];

int main()

{

	int k,i;long long max=2,min=2;

	scanf("%d",&k);

	for(i=0;i<k;i++)

	{

		scanf("%d",&x[i]);

	}

	for(i=k-1;i>=0;i--)

	{

		if(min%x[i]!=0) min=min/x[i]*x[i]+x[i];

		max=max/x[i]*x[i]+x[i]-1;

		if(max<min)break;

	}

	if(max>=min) printf("%lld %lld\n",min,max);

	else printf("-1\n");

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;



const int sz = 100005;

long long a[sz];

long long k;

const long long inf = 1000000000000000000LL;



int f(int n)

{



    cout<<n<<": ";

    for(int i = 1; i<=k; i++)

    {



        int x = n%a[i];

        n-=x;

    }



    cout<<n<<endl;

    if(n==2) return 1;

    return 0;



}



long long foo(long long n)

{



    for(int i = 1; i<=k; i++)

    {



        int x = n%a[i];

        n-=x;

    }

    return n;

}





int main()

{



    scanf("%lld", &k);



    for(int i = 1; i<=k; i++) scanf("%lld", &a[i]);





    // finding upper bound;



    long long lo = 1, hi = 1e18, mid, top = -1, lolo = inf;



    for(int j = 0; j<100; j++)

    {



        mid = (hi+lo)/2;



        long long x = foo(mid);



        if(x==2)

        {



            top = max(top, mid);

            lo = mid+1;

        }

        else if(x<2)

        {

            lo = mid+1;

        }



        else hi = mid;



    }



    lo = 1;

    hi = 1e18;

    for(int j = 0; j<100; j++)

    {



        mid = (hi+lo)/2;



        long long x = foo(mid);



        if(x==2)

        {



            lolo = min(lolo, mid);

            hi = mid;

        }

        else if(x<2)

        {

            lo = mid+1;

        }



        else hi = mid;



    }



    if(top == -1) cout<<-1<<endl;



    else cout<<lolo<<" "<<top<<endl;





}


// Optimized solution to the same problem (faster):
#include<stdio.h>

int x[100005];

int main()

{

	int k,i;long long max=2,min=2;

	scanf("%d",&k);

	for(i=0;i<k;i++)

	{

		scanf("%d",&x[i]);

	}

	for(i=k-1;i>=0;i--)

	{

		if(min%x[i]!=0) min=min/x[i]*x[i]+x[i];

		max=max/x[i]*x[i]+x[i]-1;

		if(max<min)break;

	}

	if(max>=min) printf("%lld %lld\n",min,max);

	else printf("-1\n");

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<bits/stdc++.h>



using namespace std;



#define td typedef

td long long ll;



ll in()

{

    ll a;

    scanf("%lld",&a);

    return a;

}



ll kola[100005];



int main()

{

    ll n=in();

    for(int i=0;i<n;i++)

        kola[i]=in();

    ll mn=-1,mx=-1;

    ll lo=2,hi=1000000000000000000,mid=(hi+lo)/2;

    while(hi>=lo)

    {

        ll ase=mid;

        for(int i=0;i<n;i++)

        {

            ase=(ase/kola[i])*kola[i];

        }

        if(ase==2)

        {

            hi=mid-1;

            mn=mid;

        }

        else if(ase>2)

            hi=mid-1;

        else

            lo=mid+1;

        mid=(hi+lo)/2;

    }

    lo=2,hi=1000000000000000000,mid=(hi+lo)/2;

    while(hi>=lo)

    {

        ll ase=mid;

        for(int i=0;i<n;i++)

        {

            ase=(ase/kola[i])*kola[i];

        }

        if(ase==2)

        {

            lo=mid+1;

            mx=mid;

        }

        else if(ase>2)

            hi=mid-1;

        else

            lo=mid+1;

        mid=(hi+lo)/2;

    }

    if(mn==-1)

        printf("-1\n");

    else

        printf("%lld %lld\n",mn,mx);

}


// Optimized solution to the same problem (faster):
#include<stdio.h>

int x[100005];

int main()

{

	int k,i;long long max=2,min=2;

	scanf("%d",&k);

	for(i=0;i<k;i++)

	{

		scanf("%d",&x[i]);

	}

	for(i=k-1;i>=0;i--)

	{

		if(min%x[i]!=0) min=min/x[i]*x[i]+x[i];

		max=max/x[i]*x[i]+x[i]-1;

		if(max<min)break;

	}

	if(max>=min) printf("%lld %lld\n",min,max);

	else printf("-1\n");

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<bits/stdc++.h>

using namespace std;



#define ll      long long

#define MAX     1000007

#define inf     99999999999999

#define MOD     1000000007

#define pii     pair<int,int>

#define FIN     freopen("input.txt","r",stdin);

#define FOUT    freopen("output.txt","w",stdout);



ll k,temp;

vector<ll> v;



ll func(ll val)

{

    ll tt = val;

    for(int i=0; i<k; i++)

    {

        ll temp = val%v[i];

        val = val - temp;

    }

    return val;

}



int main ()

{

    cin>>k;

    ll tt = k;

    while(tt--)

    {

        scanf("%lld",&temp);

        v.push_back(temp);

    }

    ll mn=-1,mx=-1;

    ll lo=1,hi = 1e16,mid;

    while(lo<=hi)

    {

        mid = (lo+hi)>>1;

        temp = func(mid);

        if(temp ==2)

        {

            mn = mid;

            hi = mid - 1;

        }

        else if(temp>2)

        {

            hi = mid -1;

        }

        else

        {

            lo = mid + 1;

        }

    }

    lo=1,hi = 1e16;

    while(lo<=hi)

    {

        mid = (lo+hi)>>1;

        temp = func(mid);

        if(temp ==2)

        {

            mx = mid;

            lo = mid + 1;

        }

        else if(temp>2)

        {

            hi = mid -1;

        }

        else

        {

            lo = mid + 1;

        }

    }

    if(mx==-1 && mn==-1)

        printf("-1\n");

    else

        printf("%lld %lld\n",mn,mx);

    return 0;

}




// Optimized solution to the same problem (faster):
#include<stdio.h>

int x[100005];

int main()

{

	int k,i;long long max=2,min=2;

	scanf("%d",&k);

	for(i=0;i<k;i++)

	{

		scanf("%d",&x[i]);

	}

	for(i=k-1;i>=0;i--)

	{

		if(min%x[i]!=0) min=min/x[i]*x[i]+x[i];

		max=max/x[i]*x[i]+x[i]-1;

		if(max<min)break;

	}

	if(max>=min) printf("%lld %lld\n",min,max);

	else printf("-1\n");

}

// Fastest known solution for this problem: