stablegradients/pie-gem5-pairs huggingface dataset:
// Slower C++ solution:
#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;

}

// Faster C++ solution for the same problem (measured speedup: 5.343144168325036x):
#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;

}
// Slower C++ solution:
#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;

}


// Faster C++ solution for the same problem (measured speedup: 5.323603058108113x):
#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;

}
// Slower C++ solution:
#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;

}


// Faster C++ solution for the same problem (measured speedup: 5.38161348366094x):
#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;

}
// Slower C++ solution:
#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;





}


// Faster C++ solution for the same problem (measured speedup: 5.364052453714318x):
#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;

}
// Slower C++ solution:
#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;

}

// Faster C++ solution for the same problem (measured speedup: 5.276332345634056x):
#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;

}
// Slower C++ solution:
#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;

}

// Faster C++ solution for the same problem (measured speedup: 5.311963763906827x):
#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");

}
// Slower C++ solution:
#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;

}

// Faster C++ solution for the same problem (measured speedup: 5.369756959123497x):
#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");

}
// Slower C++ solution:
#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;





}


// Faster C++ solution for the same problem (measured speedup: 5.352710952081957x):
#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");

}
// Slower C++ solution:
#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);

}


// Faster C++ solution for the same problem (measured speedup: 5.268424709347825x):
#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");

}
// Slower C++ solution:
#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;

}




// Faster C++ solution for the same problem (measured speedup: 5.336135829999762x):
#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");

}
// Slower C++ solution:
#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;





}


// Faster C++ solution for the same problem (measured speedup: 5.3529823590057415x):
#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");

}
// Slower C++ solution:
#include<iostream>

#include<cstdio>

#include<vector>

#include<algorithm>

#include<queue>

#include<cmath>

#include<cstring>

using namespace std;

int a[100005];

int n;

int main() {

    scanf("%d",&n);

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

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

    }

    long long maxx=2,minn=2;

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

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

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

	    } 

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

    }

    if(maxx>=minn){

        printf("%lld %lld\n",minn,maxx);

    }

    else {

	   printf("-1\n");

   }



    return 0;

}


// Faster C++ solution for the same problem (measured speedup: 5.266015903462943x):
#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");

}
// Slower C++ solution:
#include <bits/stdc++.h>



using namespace std;



#define sq(a) ((a) * (a))

#define all(x) (x).begin(), (x).end()

#define pb push_back

#define mp(a, b) make_pair(a, b)

#define what_is(x) cerr << fixed << setprecision(2) << #x << " = " << x << endl

#define setbitj(n, j) (n |= (1 << (j)))

#define isbitjOn(n, j) (((n & (1 << (j))) > 0) ? 1 : 0)

#define safeMod(a, m) ((((a)%(m))+(m))%(m))/*handling negative sign of remainder*/



typedef long long ll;

typedef unsigned long long ull;

typedef pair<int, int> pii;

typedef vector<int> vi;

typedef vector<pii> vii;



const double EPS = 1e-9;

const int INF = 0x3f3f3f3f;

const double PI = acos(-1.0);

const int MAX = 100005;

const int MOD = 1000000007;



inline bool isEq(double a, double b){return abs(a - b) < EPS;}

inline double toRad(double deg){return deg*PI/180;}

inline double toDeg(double rad){return rad*180/PI;}



inline int geti(int &_int){return scanf("%d", &_int);}

inline int getii(int &_int, int &_int2){return scanf("%d %d", &_int, &_int2);}

inline int getiii(int &_int, int &_int2, int &_int3){return scanf("%d %d %d", &_int, &_int2, &_int3);}



inline int getl(ll &_ll){return scanf("%lld", &_ll);}

inline int getll(ll &_ll, ll &_ll2){return scanf("%lld %lld", &_ll, &_ll2);}

inline int getlll(ll &_ll, ll &_ll2, ll &_ll3){return scanf("%lld %lld %lld", &_ll, &_ll2, &_ll3);}



inline int getd(double &_double){return scanf("%lf", &_double);}

inline int getdd(double &_double, double &_double2){return scanf("%lf %lf", &_double, &_double2);}



inline int getstr(char *str){return scanf("%s", str);}



//#define isValid(a, b) (a >= 0 && a < b)

//int dr[]  =  {0, -1, -1, -1,  0,  1, 1, 1};

//int dc[]  =  {1,  1,  0, -1, -1, -1, 0, 1};



int main(int argc, char* argv[])

{

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

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

    //ios_base::sync_with_stdio(false); cin.tie(NULL);

    int k, ara[MAX];

    geti(k);

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

        geti(ara[i]);

    ll low, high;

    ll l = 0, h = 1e18, mid;

    while(l <= h){

        mid = (l+h)/2;

        ll n = mid;

        for(int i = 0; i < k; i++){n=(n/ara[i])*ara[i];}

        if(n >= 2){

            h = mid-1;

            low = mid;

        }

        else

            l = mid+1;

    }

    l = 0;

    h = 1e18;

    while(l <= h){

        mid = (l+h)/2;

        ll n = mid;

        for(int i = 0; i < k; i++){n=(n/ara[i])*ara[i];}

        if(n <= 2){

            l = mid+1;

            high = mid;

        }

        else

            h = mid-1;

    }

    if(low <= high)

        printf("%lld %lld\n", low, high);

    else

        printf("-1\n");

    return 0;

}


// Faster C++ solution for the same problem (measured speedup: 5.309361832517899x):
#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");

}