#include <iostream>
#include <cstdio>
#include <cmath>
#include <map>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <deque>
#include <string>
#include <set>
#include <limits.h>

#define inp(x) scanf("%d",&x)
#define inp_l(x) scanf("%lld",&x)
#define inp_d(x) scanf("%lf",&x)
#define MOD 1000000007

using namespace std;

typedef long long int ll;
typedef vector <int> VI;
typedef vector <long long int> VLL;
typedef pair<int,int> PI;
typedef pair<ll,ll> PLL;

struct data
{
	ll x;
	ll y;
	ll d1;
	ll d2;
	/* data */
};

int main()
{
	ll n,x1,y1,x2,y2,i,r1,r2,d1,d2,r11,r21,x,y;
	vector <data> arr;
	map <ll,ll> S1,S2;
	cin >> n >> x1 >> y1 >> x2 >> y2;
	r1=r2=0ll;
	for(i=0;i<n;i++)
	{
		cin >> x >> y;
		d1=(x-x1)*(x-x1)+(y-y1)*(y-y1);
		d2=(x-x2)*(x-x2)+(y-y2)*(y-y2);
		data tmp;
		tmp.x=x;
		tmp.y=y;
		tmp.d1=d1;
		tmp.d2=d2;
		arr.push_back(tmp);
		if(S2.find(d2)==S2.end())
		{
			S2[d2]=1;
		}
		else
		{
			S2[d2]=S2[d2]+1;
		}
		r2=max(r2,d2);
	}

	for(i=0;i<n;i++)
	{
		r11=max(r1,arr[i].d1);
		S2[arr[i].d2]--;
		if(S2[arr[i].d2]==0)
		{
			S2.erase(S2.find(arr[i].d2));
		}
		if(S2.empty())
			r21=0ll;
		else
			r21=(S2.rbegin())->first;
		if(r1+r2>r11+r21)
		{
			r1=r11;
			r2=r21;
			if(S1.find(arr[i].d1)==S1.end())
			{
				S1[arr[i].d1]=1;
			}
			else
			{
				S1[arr[i].d1]++;
			}
		}
		else
		{
			if(S2.find(arr[i].d2)==S2.end())
			{
				S2[arr[i].d2]=1;
			}
			else
			{
				S2[arr[i].d2]++;
			}
		}
	}
	cout << r1+r2 << endl;
	return 0;
}


#include <iostream>
#include <cstdio>
#include <cmath>
#include <map>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <deque>
#include <string>
#include <set>
#include <limits.h>

#define inp(x) scanf("%d",&x)
#define inp_l(x) scanf("%lld",&x)
#define inp_d(x) scanf("%lf",&x)
#define MOD 1000000007

using namespace std;

typedef long long int ll;
typedef vector <int> VI;
typedef vector <long long int> VLL;
typedef pair<int,int> PI;
typedef pair<ll,ll> PLL;

int main()
{
	ios_base::sync_with_stdio(false); cin.tie(0);
	ll n,x1,y1,x2,y2,d1,d2,r1,r2,i,x,y;
	cin >> n >> x1 >> y1 >> x2 >> y2;

	vector <PLL> arr(n);
	for(i=0;i<n;i++)
	{
		cin >> x >> y;
		d1=(x-x1)*(x-x1)+(y-y1)*(y-y1);
		d2=(x-x2)*(x-x2)+(y-y2)*(y-y2);
		arr[i]=make_pair(d1,d2);
	}
	sort(arr.begin(),arr.end());
	vector <ll> arr1(n+1);
	arr1[n]=0;
	for(i=n-1;i>=0;i--)
	{
		arr1[i]=max(arr1[i+1],arr[i].second);
	}
	ll ans=arr1[0];
	for(i=0;i<n;i++)
	{
		r1=arr[i].first;
		r2=arr1[i+1];
		ans=min(ans,r1+r2);
	}
	cout << ans << endl;

	return 0;
}


#include <iostream>
#include <algorithm>

typedef long long int ll;
using namespace std;

int main()
{
	ll n,x1,x2,y1,y2,r1,r2,x,y,d1,d2,i,p1,p2;
	r1=r2=0ll;
	cin >> n >> x1 >> y1 >> x2 >> y2;
	for(i=0;i<n;i++)
	{
		cin >> x >> y;
		d1=(x1-x)*(x1-x)+(y1-y)*(y1-y);
		d2=(x2-x)*(x2-x)+(y2-y)*(y2-y);

		p1=max(r1,d1)+r2;
		p2=r1+max(r2,d2);
		if(p1<p2)
		{
			r1=max(r1,d1);
		}
		else
		{
			r2=max(r2,d2);
		}
	}

	ll ans = r1+r2;
	cout << ans << endl;
	return 0;
}


#include <iostream>
#include <algorithm>

typedef long long int ll;
using namespace std;

int main()
{
	ll n,x1,x2,y1,y2,r1,r2,x,y,d1,d2,i;
	r1=r2=0ll;
	cin >> n >> x1 >> y1 >> x2 >> y2;
	for(i=0;i<n;i++)
	{
		cin >> x >> y;
		d1=(x1-x)*(x1-x)+(y1-y)*(y1-y);
		d2=(x2-x)*(x2-x)+(y2-y)*(y2-y);

		if(d1>r1 && d2>r2)
		{
			if(d1<d2)
			{
				r1=max(r1,d1);
			}
			else
			{
				r2=max(r2,d2);
			}
		}
	}

	ll ans = r1+r2;
	cout << ans << endl;
	return 0;
}


#include <iostream>
#include <cstdio>
#include <cmath>
#include <map>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <deque>
#include <string>
#include <set>
#include <limits.h>

#define inp(x) scanf("%d",&x)
#define inp_l(x) scanf("%lld",&x)
#define inp_d(x) scanf("%lf",&x)
#define MOD 1000000007

using namespace std;

typedef long long int ll;
typedef vector <int> VI;
typedef vector <long long int> VLL;
typedef pair<int,int> PI;
typedef pair<ll,ll> PLL;

int main()
{
	ios_base::sync_with_stdio(false); cin.tie(0);
	ll n,x1,y1,x2,y2,d1,d2,r1,r2,i,x,y;
	cin >> n >> x1 >> y1 >> x2 >> y2;

	vector <PLL> arr(n);
	for(i=0;i<n;i++)
	{
		cin >> x >> y;
		d1=(x-x1)*(x-x1)+(y-y1)*(y-y1);
		d2=(x-x2)*(x-x2)+(y-y2)*(y-y2);
		arr[i]=make_pair(d1,d2);
	}
	sort(arr.begin(),arr.end());
	vector <ll> arr1(n+1);
	arr1[n]=0;
	for(i=n-1;i>=0;i--)
	{
		arr1[i]=max(arr1[i+1],arr[i].second);
	}
	ll ans=8000000000000000000ll;
	for(i=0;i<n;i++)
	{
		r1=arr[i].first;
		r2=arr1[i+1];
		ans=min(ans,r1+r2);
	}
	cout << ans << endl;

	return 0;
}


#include <iostream>
#include <algorithm>

typedef long long int ll;
using namespace std;

int main()
{
	ll n,x1,x2,y1,y2,r1,r2,x,y,d1,d2,i;
	r1=r2=0ll;
	cin >> n >> x1 >> y1 >> x2 >> y2;
	for(i=0;i<n;i++)
	{
		cin >> x >> y;
		d1=(x1-x)*(x1-x)+(y1-y)*(y1-y);
		d2=(x2-x)*(x2-x)+(y2-y)*(y2-y);

		if(d1>r1 && d2>r2)
		{
			if(d1-r1<d2-r2)
			{
				r1=d1;
			}
			else
			{
				r2=d2;
			}
		}
	}

	ll ans = r1+r2;
	cout << ans << endl;
	return 0;
}


#include <iostream>
#include <cstdio>
#include <cmath>
#include <map>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <deque>
#include <string>
#include <set>
#include <limits.h>

#define max(a,b) (a>b?)a:b
#define inp(x) scanf("%d",&x)
#define inp_l(x) scanf("%lld",&x)
#define inp_d(x) scanf("%lf",&x)
#define MOD 1000000007

using namespace std;

typedef long long int ll;
typedef vector <int> VI;
typedef vector <long long int> VLL;
typedef pair<int,int> PI;
typedef pair<ll,ll> PLL;

struct data
{
	ll x;
	ll y;
	ll d1;
	ll d2;
	/* data */
};

int main()
{
	ll n,x1,y1,x2,y2,i,r1,r2,d1,d2,r11,r21,x,y;
	vector <data> arr;
	map <ll,ll> S1,S2;
	cin >> n >> x1 >> y1 >> x2 >> y2;
	r1=r2=0ll;
	for(i=0;i<n;i++)
	{
		cin >> x >> y;
		d1=(x-x1)*(x-x1)+(y-y1)*(y-y1);
		d2=(x-x2)*(x-x2)+(y-y2)*(y-y2);
		data tmp;
		tmp.x=x;
		tmp.y=y;
		tmp.d1=d1;
		tmp.d2=d2;
		arr.push_back(tmp);
		if(S2.find(d2)==S2.end())
		{
			S2[d2]=1;
		}
		else
		{
			S2[d2]=S2[d2]+1;
		}
		r2=max(r2,d2);
	}

	for(i=0;i<n;i++)
	{
		r11=max(r1,arr[i].d1);
		S2[arr[i].d2]--;
		if(S2[arr[i].d2]==0)
		{
			S2.erase(S2.find(arr[i].d2));
		}
		if(S2.empty())
			r21=0ll;
		else
			r21=(S2.rbegin())->first;
		if(r1+r2>r11+r21)
		{
			r1=r11;
			r2=r21;
			if(S1.find(arr[i].d1)==S1.end())
			{
				S1[arr[i].d1]=1;
			}
			else
			{
				S1[arr[i].d1]++;
			}
		}
		else
		{
			if(S2.find(arr[i].d2)==S2.end())
			{
				S2[arr[i].d2]=1;
			}
			else
			{
				S2[arr[i].d2]++;
			}
		}
	}
	cout << r1+r2 << endl;
	return 0;
}


#include <iostream>
#include <map>
#include <algorithm>

typedef long long int ll;
using namespace std;

int main()
{
	ll n,x1,x2,y1,y2,r1,r2,x,y,d1,d2,i,p1,p2;
	pair <ll, ll> arr[100000];
	r1=r2=0ll;
	cin >> n >> x1 >> y1 >> x2 >> y2;
	for(i=0;i<n;i++)
	{
		cin >> x >> y;
		arr[i]=make_pair(x,y);
		d1=(x1-x)*(x1-x)+(y1-y)*(y1-y);
		d2=(x2-x)*(x2-x)+(y2-y)*(y2-y);
		if(d1<d2)
		{
			r1=max(r1,d1);
		}
		else
		{
			r2=max(r2,d2);
		}
	}
	bool flag;
	if(r1>r2)
	{
		flag=true;
		r2=0ll;
	}
	else
	{
		flag=false;
		r1=0ll;
	}
	for(i=0;i<n;i++)
	{
		x=arr[i].first;
		y=arr[i].second;
		d1=(x1-x)*(x1-x)+(y1-y)*(y1-y);
		d2=(x2-x)*(x2-x)+(y2-y)*(y2-y);
		if(flag)
		{
			if(d1>r1)
			{
				r2=max(r2,d2);
			}
		}
		else
		{
			if(d2>r2)
			{
				r1=max(r1,d1);
			}
		}

	}
	cout << r1+r2 << endl;
	return 0;
}


#include<cstdio>
#include<algorithm>
using namespace std;
long long ans,now,x1,y1,x2,y2,x,y;
int n,i,j;
struct point
{
	long long d1,d2;
}p[2010];
long long sqr(long long x){return x*x;}
long long dis1(){return sqr(x1-x)+sqr(y1-y);}
long long dis2(){return sqr(x2-x)+sqr(y2-y);}
bool cmp(point a,point b){return a.d1<b.d1;}
int main()
{
	scanf("%d",&n);
	scanf("%I64d%I64d%I64d%I64d",&x1,&y1,&x2,&y2);
	for (i=1;i<=n;i++)
	{
		scanf("%I64d%I64d",&x,&y);
		p[i].d1=dis1();
		p[i].d2=dis2();
	}
	sort(p+1,p+n+1,cmp);
	ans=p[n].d1;
	for (i=1;i<=n;i++)
	{
		now=0;
		for (j=i+1;j<=n;j++)
		  if (now<p[j].d2) now=p[j].d2;
		now+=p[i].d1;
		if (now<ans) ans=now;
	}
	printf("%I64d\n",ans);
}


#include<cstdio>
#include<algorithm>
using namespace std;
long long ans,now,x1,y1,x2,y2,x,y;
int n,i,j;
struct point
{
	long long d1,d2;
}p[2010];
long long sqr(long long x){return x*x;}
long long dis1(){return sqr(x1-x)+sqr(y1-y);}
long long dis2(){return sqr(x2-x)+sqr(y2-y);}
bool cmp(point a,point b){return a.d1<b.d1;}

int main()
{
	scanf("%d",&n);
	scanf("%I64d%I64d%I64d%I64d",&x1,&y1,&x2,&y2);
	for (i=1;i<=n;i++)
	{
		scanf("%I64d%I64d",&x,&y);
		p[i].d1=dis1();
		p[i].d2=dis2();
	}
	sort(p+1,p+n+1,cmp);
	ans=p[n].d1;
	for (i=0;i<=n;i++)
	{
		now=0;
		for (j=i+1;j<=n;j++)
		  if (now<p[j].d2) now=p[j].d2;
		now+=p[i].d1;
		if (now<ans) ans=now;
	}
	printf("%I64d\n",ans);
}


#include<cstdio>
#include<algorithm>
using namespace std;
long long ans,now,x1,y1,x2,y2,x,y,maxx[2010];
int n,i,j;
struct point
{
	long long d1,d2;
}p[2010];
long long sqr(long long x){return x*x;}
long long dis1(){return sqr(x1-x)+sqr(y1-y);}
long long dis2(){return sqr(x2-x)+sqr(y2-y);}
bool cmp(point a,point b){return a.d1<b.d1;}

int main()
{
	scanf("%d",&n);
	scanf("%I64d%I64d%I64d%I64d",&x1,&y1,&x2,&y2);
	for (i=1;i<=n;i++)
	{
		scanf("%I64d%I64d",&x,&y);
		p[i].d1=dis1();
		p[i].d2=dis2();
	}
	sort(p+1,p+n+1,cmp);
	ans=p[n].d1;
	for (i=n;i>=1;i++)
	  maxx[i]=max(maxx[i+1],p[i].d2);
	for (i=0;i<=n;i++)
	{
		now=p[i].d1+maxx[i+1];
		if (now<ans) ans=now;
	}
	printf("%I64d\n",ans);
}


#include<cstdio>
#include<algorithm>
using namespace std;
long long ans,now,x1,y1,x2,y2;
int n,i,j;
struct point
{
	long long d1,d2,x,y;
}p[2010];
long long sqr(long long x)
{
	return x*x;
}
long long dis1(int i)
{
	return sqr(x1-p[i].x)+sqr(y1-p[i].y);
}
long long dis2(int i)
{
	return sqr(x2-p[i].x)+sqr(y2-p[i].y);
}
bool cmp(point a,point b)
{
	return a.d1<b.d1;
}
int main()
{
	scanf("%d",&n);
	scanf("%I64d%I64d%I64d%I64d",&x1,&y1,&x2,&y2);
	for (i=1;i<=n;i++) scanf("%I64d%I64d",&p[i].x,&p[i].y);
	for (i=1;i<=n;i++) {p[i].d1=dis1(i);p[i].d2=dis2(i);}
	sort(p+1,p+n+1,cmp);
	ans=p[n].d1;
	for (i=1;i<=n;i++)
	{
		now=0;
		for (j=i+1;j<=n;j++)
		  if (now<p[j].d2) now=p[j].d2;
		now+=p[i].d1;
		if (now<ans) ans=now;
	}
	printf("%I64d\n",ans);
}


#include<cstdio>
#include<algorithm>
using namespace std;
long long ans,now,maxx;
int n,x1,y1,x2,y2,i,j;
struct point
{
	long long d1,d2;
	int x,y;
}p[2010];
long long sqr(long long x)
{
	return x*x;
}
long long dis1(int i)
{
	return sqr(x1-p[i].x)+sqr(y1-p[i].y);
}
long long dis2(int i)
{
	return sqr(x2-p[i].x)+sqr(y2-p[i].y);
}
bool cmp(point a,point b)
{
	return a.d1<b.d1;
}
int main()
{
	scanf("%d",&n);
	scanf("%d%d%d%d",&x1,&y1,&x2,&y2);
	for (i=1;i<=n;i++) scanf("%d%d",&p[i].x,&p[i].y);
	maxx=0;
	for (i=1;i<=n;i++) {p[i].d1=dis1(i);p[i].d2=dis2(i);if (maxx<p[i].d2) maxx=p[i].d2;}
	sort(p+1,p+n+1,cmp);
	ans=p[n].d1+maxx;
	for (i=1;i<=n;i++)
	{
		if (p[i].d1==p[i+1].d1) continue;
		now=0;
		for (j=i+1;j<=n;j++)
		  if (now<p[j].d2) now=p[j].d2;
		now+=p[i].d1;
		if (now<ans) ans=now;
	}
	printf("%I64d\n",ans);
}


#include<cstdio>
#include<algorithm>
using namespace std;
long long ans,now,x1,y1,x2,y2,x,y;
int n,i,j;
struct point
{
	long long d1,d2;
}p[2010];
long long sqr(long long x){return x*x;}
long long dis1(){return sqr(x1-x)+sqr(y1-y);}
long long dis2(){return sqr(x2-x)+sqr(y2-y);}
bool cmp(point a,point b){return a.d1<b.d1;}
bool cmp2(point a,point b){return a.d2<b.d2;}

int main()
{
	scanf("%d",&n);
	scanf("%I64d%I64d%I64d%I64d",&x1,&y1,&x2,&y2);
	for (i=1;i<=n;i++)
	{
		scanf("%I64d%I64d",&x,&y);
		p[i].d1=dis1();
		p[i].d2=dis2();
	}
	sort(p+1,p+n+1,cmp);
	ans=p[n].d1;
	for (i=1;i<=n;i++)
	{
		now=0;
		for (j=i+1;j<=n;j++)
		  if (now<p[j].d2) now=p[j].d2;
		now+=p[i].d1;
		if (now<ans) ans=now;
	}
	sort(p+1,p+n+1,cmp2);
	for (i=1;i<=n;i++)
	{
		now=0;
		for (j=i+1;j<=n;j++)
		  if (now<p[j].d1) now=p[j].d1;
		now+=p[i].d2;
		if (now<ans) ans=now;
	}
	printf("%I64d\n",ans);
}


#include<cstdio>
#include<algorithm>
using namespace std;
long long ans,now,x1,y1,x2,y2,x,y,maxx[2010];
int n,i,j;
struct point
{
	long long d1,d2;
}p[2010];
long long sqr(long long x){return x*x;}
long long dis1(){return sqr(x1-x)+sqr(y1-y);}
long long dis2(){return sqr(x2-x)+sqr(y2-y);}
bool cmp(point a,point b){return a.d1<b.d1;}

int main()
{
	scanf("%d",&n);
	scanf("%I64d%I64d%I64d%I64d",&x1,&y1,&x2,&y2);
	for (i=1;i<=n;i++)
	{
		scanf("%I64d%I64d",&x,&y);
		p[i].d1=dis1();
		p[i].d2=dis2();
	}
	sort(p+1,p+n+1,cmp);
	ans=p[n].d1;
	for (i=n;i>=1;i--)
	  maxx[i]=max(maxx[i+1],p[i].d2);
	for (i=0;i<=n;i++)
	{
		now=p[i].d1+maxx[i+1];
		if (now<ans) ans=now;
	}
	printf("%I64d\n",ans);
}


#include<cstdio>
#include<algorithm>
using namespace std;
long long ans,now,maxx,x1,y1,x2,y2;
int n,i,j;
struct point
{
	long long d1,d2,x,y;
}p[2010];
long long sqr(long long x)
{
	return x*x;
}
long long dis1(int i)
{
	return sqr(x1-p[i].x)+sqr(y1-p[i].y);
}
long long dis2(int i)
{
	return sqr(x2-p[i].x)+sqr(y2-p[i].y);
}
bool cmp(point a,point b)
{
	return a.d1<b.d1;
}
int main()
{
	scanf("%d",&n);
	scanf("%I64d%I64d%I64d%I64d",&x1,&y1,&x2,&y2);
	for (i=1;i<=n;i++) scanf("%I64d%I64d",&p[i].x,&p[i].y);
	maxx=0;
	for (i=1;i<=n;i++) {p[i].d1=dis1(i);p[i].d2=dis2(i);if (maxx<p[i].d2) maxx=p[i].d2;}
	sort(p+1,p+n+1,cmp);
	ans=p[n].d1+maxx;
	for (i=1;i<=n;i++)
	{
		now=0;
		for (j=i+1;j<=n;j++)
		  if (now<p[j].d2) now=p[j].d2;
		now+=p[i].d1;
		if (now<ans) ans=now;
	}
	printf("%I64d\n",ans);
}


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

typedef long long lli;
lli dist1[2005],dist2[2005];

int main()
{

    lli n,x1,x2,y1,y2;
    scanf("%lld %lld %lld %lld %lld",&n,&x1,&y1,&x2,&y2);
    for(int i=1;i<=n;i++)
    {
        lli a,b;
        scanf("%lld %lld",&a,&b);
        dist1[i]=((x1-a)*(x1-a)+(y1-b)*(y1-b));
        dist2[i]=((x2-a)*(x2-a)+(y2-b)*(y2-b));

    }
    dist1[n+1]=dist2[n+1]=0;
    //printf("%lld %lld ",dist1[1],dist2[1]);
    lli r1,r2=0,minm=(lli)1e18;

    for(int i=1;i<=n+1;i++)
    {
        r1=dist1[i];
        r2=0;
        for(int i=1;i<=n+1;i++)
        {
            if(dist1[i]>r1)
            {
                r2=max(r2,dist2[i]);
            }
        }
        minm=min(minm,r1+r2);
    }

   /* for(int i=1;i<=n;i++)
    {
        r1=dist2[i];
        r2=0;
        for(int i=1;i<=n;i++)
        {
            if(dist2[i]>r1)
            {
                r2=max(r2,dist1[i]);
            }
        }
        minm=min(minm,r1+r2);
    }*/

    printf("%lld",minm);
    return 0;
}


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

typedef long long lli;
lli dist1[2005],dist2[2005];

int main()
{

    int n,x1,x2,y1,y2;
    scanf("%d %d %d %d %d",&n,&x1,&y1,&x2,&y2);
    for(int i=1;i<=n;i++)
    {
        int a,b;
        scanf("%d %d",&a,&b);
        dist1[i]=(lli)(pow(x1-a,2)+pow(y1-b,2));
        dist2[i]=(lli)(pow(x2-a,2)+pow(y2-b,2));

    }
    lli r1,r2=0,minm=(lli)1e18;

    for(int i=1;i<=n;i++)
    {
        r1=dist1[i];
        r2=0;
        for(int i=1;i<=n;i++)
        {
            if(dist1[i]>r1)
            {
                r2=max(r2,dist2[i]);
            }
        }
        minm=min(minm,r1+r2);
    }

    printf("%lld",minm);
    return 0;
}


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

typedef long long lli;
lli dist1[2005],dist2[2005];

int main()
{

    int n,x1,x2,y1,y2;
    scanf("%d %d %d %d %d",&n,&x1,&y1,&x2,&y2);
    for(int i=1;i<=n;i++)
    {
        int a,b;
        scanf("%d %d",&a,&b);
        dist1[i]=(lli)(pow(x1-a,2)+pow(y1-b,2));
        dist2[i]=(lli)(pow(x2-a,2)+pow(y2-b,2));

    }
    lli maxm=0,save;
    for(int i=1;i<=n;i++)
    {
        if(min(dist1[i],dist2[i])>maxm)
        {
            maxm=min(dist1[i],dist2[i]);
            if(dist1[i]<dist2[i])save=1;
            else save=2;
        }
    }
    lli tmp=0;
    if(save==1)
    {
        for(int i=1;i<=n;i++)
        {
            if(dist1[i]>maxm)
            {
                tmp=max(tmp,dist2[i]);
            }
        }
    }
    else
    {
        for(int i=1;i<=n;i++)
        {
            if(dist2[i]>maxm)
            {
                tmp=max(tmp,dist1[i]);
            }
        }
    }
    printf("%lld",maxm+tmp);
    return 0;
}


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

typedef long long lli;
lli dist1[2005],dist2[2005];

int main()
{

    int n,x1,x2,y1,y2;
    scanf("%d %d %d %d %d",&n,&x1,&y1,&x2,&y2);
    for(int i=1;i<=n;i++)
    {
        int a,b;
        scanf("%d %d",&a,&b);
        dist1[i]=(lli)(pow(x1-a,2)+pow(y1-b,2));
        dist2[i]=(lli)(pow(x2-a,2)+pow(y2-b,2));

    }
    lli maxm=0,save;
    for(int i=1;i<=n;i++)
    {
        if(min(dist1[i],dist2[i])>maxm)
        {
            maxm=min(dist1[i],dist2[i]);
            if(dist1[i]<dist2[i])save=1;
            else save=2;
        }
    }
    lli tmp=0;
    lli minm=(lli)1e18;
    if(save==1)
    {
        for(int i=1;i<=n;i++)
        {
            if(dist1[i]>maxm)
            {
                tmp=max(tmp,dist2[i]);
            }
        }
    }

    else
    {
        for(int i=1;i<=n;i++)
        {
            if(dist2[i]>maxm)
            {
                minm=min(dist2[i],tmp+maxm);
                tmp=max(tmp,dist1[i]);
            }
        }
    }
    printf("%lld",minm);
    return 0;
}


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

typedef long long lli;
lli dist1[2005],dist2[2005];

int main()
{

    int n,x1,x2,y1,y2;
    scanf("%d %d %d %d %d",&n,&x1,&y1,&x2,&y2);
    for(int i=1;i<=n;i++)
    {
        int a,b;
        scanf("%d %d",&a,&b);
        dist1[i]=(lli)(pow(x1-a,2)+pow(y1-b,2));
        dist2[i]=(lli)(pow(x2-a,2)+pow(y2-b,2));

    }
    lli maxm=0,save;
    for(int i=1;i<=n;i++)
    {
        if(min(dist1[i],dist2[i])>maxm)
        {
            maxm=min(dist1[i],dist2[i]);
            if(dist1[i]<dist2[i])save=1;
            else save=2;
        }
    }
    lli tmp=0;
    if(save==1)
    {
        for(int i=1;i<=n;i++)
        {
            if(dist1[i]>maxm)
            {
                tmp=max(tmp,dist2[i]);
            }
        }
    }
    lli minm;
    else
    {
        for(int i=1;i<=n;i++)
        {
            if(dist2[i]>maxm)
            {
                minm=min(dist2[i],tmp+maxm);
                tmp=max(tmp,dist1[i]);
            }
        }
    }
    printf("%lld",minm);
    return 0;
}


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

typedef long long lli;
lli dist1[2005],dist2[2005];

int main()
{

    lli n,x1,x2,y1,y2;
    scanf("%lld %lld %lld %lld %lld",&n,&x1,&y1,&x2,&y2);
    for(int i=1;i<=n;i++)
    {
        lli a,b;
        scanf("%lld %lld",&a,&b);
        dist1[i]=((x1-a)*(x1-a)+(y1-b)*(y1-b));
        dist2[i]=((x2-a)*(x2-a)+(y2-b)*(y2-b));

    }
    //printf("%lld %lld ",dist1[1],dist2[1]);
    lli r1,r2=0,minm=(lli)1e18;

    for(int i=1;i<=n;i++)
    {
        r1=dist1[i];
        r2=0;
        for(int i=1;i<=n;i++)
        {
            if(dist1[i]>r1)
            {
                r2=max(r2,dist2[i]);
            }
        }
        minm=min(minm,r1+r2);
    }

    for(int i=1;i<=n;i++)
    {
        r1=dist2[i];
        r2=0;
        for(int i=1;i<=n;i++)
        {
            if(dist2[i]>r1)
            {
                r2=max(r2,dist1[i]);
            }
        }
        minm=min(minm,r1+r2);
    }

    printf("%lld",minm);
    return 0;
}


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

typedef long long lli;
lli dist1[2005],dist2[2005];

int main()
{

    int n,x1,x2,y1,y2;
    scanf("%d %d %d %d %d",&n,&x1,&y1,&x2,&y2);
    for(int i=1;i<=n;i++)
    {
        int a,b;
        scanf("%d %d",&a,&b);
        dist1[i]=(lli)(pow(x1-a,2)+pow(y1-b,2));
        dist2[i]=(lli)(pow(x2-a,2)+pow(y2-b,2));

    }
    lli maxm=0,save;
    for(int i=1;i<=n;i++)
    {
        if(min(dist1[i],dist2[i])>maxm)
        {
            maxm=min(dist1[i],dist2[i]);
            if(dist1[i]<dist2[i])save=1;
            else save=2;
        }
    }
    lli tmp=0;
    lli minm;
    if(save==1)
    {
        for(int i=1;i<=n;i++)
        {
            if(dist1[i]>maxm)
            {
                tmp=max(tmp,dist2[i]);
            }
        }
    }

    else
    {
        for(int i=1;i<=n;i++)
        {
            if(dist2[i]>maxm)
            {
                minm=min(dist2[i],tmp+maxm);
                tmp=max(tmp,dist1[i]);
            }
        }
    }
    printf("%lld",minm);
    return 0;
}


#include <iostream>
#include <cmath>
using namespace std;

int a[100500];

struct Point
{
    int x, y;

    Point (int _x, int _y) : x(_x), y(_y) {}
    Point () : x(), y() {}

    Point operator- (const Point &A)
    {
        return Point(x - A.x, y - A.y);
    }

    void get ()
    {
        cin >> x >> y;
    }

};

struct Circle
{
    int x, y;
    double r;

     void get ()
    {
        cin >> x >> y;
        r = 0;
    }

};

double p_to_p (Point A, Point B)
{
    Point tmp = A - B;
    return sqrt(tmp.x * tmp.x + tmp.y * tmp.y);
}

double len (Circle A, Point B)
{
    Point tmp;
    tmp.x = A.x;
    tmp.y = A.y;

    return max(0.0, p_to_p(tmp, B) - A.r);

}

int main()
{
    int n;
    Circle X, Y;
    Point All[100500];
    cin >> n;
    X.get(); Y.get();

    for (int i = 0; i < n; i++)
    {
        All[i].get();
    }

    double ans = 0;

    for (int i = 0; i < n; i++)
    {
         double len1 = len(X, All[i]);
         double len2 = len(Y, All[i]);

         double r1 = abs((X.r + len1)*(X.r + len1)) + abs(Y.r * Y.r);
         double r2 = abs(X.r * X.r) + abs((Y.r + len2)*(Y.r + len2));

         if (r1 < r2)
         {
            X.r += len1;
         }
         else
         {
            Y.r += (len2);
         }
    }

   // cout << abs(X.r * X.r) << " " << abs (Y.r * Y.r) << endl;

    cout << abs(X.r * X.r) + abs(Y.r * Y.r);

    return 0;
}


#include <iostream>
#include <cmath>
#include <vector>
#include <string>
using namespace std;

int a[100500];

struct Point
{
    long long x, y;

    Point (long long _x, long long _y) : x(_x), y(_y) {}
    Point () : x(), y() {}

    Point operator- (const Point &A)
    {
        return Point(x - A.x, y - A.y);
    }

    void get ()
    {
        cin >> x >> y;
    }

};

vector < pair <long long, long long> > dist;

long long len (Point A, Point B)
{
    return (A - B).x * (A - B).x + (A- B).y * (A -  qB).y;
}

int main()
{
    int n;
    cin >> n;
    Point A,B;
    A.get(); B.get();

    Point C;

    for (int i = 0; i < n; i++)
    {
        C.get();

        dist.push_back(make_pair(len(A,C), len(B,C)));
    }
    dist.push_back(make_pair(0,0));
    long long r1 = 0;
    long long r2 = 0;
    long long ans = 1e18;

    for (int i = 0; i <= n; i++)
    {
        r1 = dist[i].first;
        r2 = 0;
        for (int j = 0; j <= n; j++)
        {
            if (dist[j].second > r1)
            {
                r2 = max(r2, dist[j].second);
            }
        }
        ans = min(ans, r1 + r2);
    }

    cout << ans;

    return 0;
}


#include <iostream>
#include <cmath>
#include <vector>
#include <string>
using namespace std;

int a[100500];

struct Point
{
    long long x, y;

    Point (long long _x, long long _y) : x(_x), y(_y) {}
    Point () : x(), y() {}

    Point operator- (const Point &A)
    {
        return Point(x - A.x, y - A.y);
    }

    void get ()
    {
        cin >> x >> y;
    }

};

vector < pair <long long, long long> > dist;

long long len (Point A, Point B)
{
    return (A - B).x * (A - B).x + (A- B).y * (A -  B).y;
}

int main()
{
    int n;
    cin >> n;
    Point A,B;
    A.get(); B.get();

    Point C;

    for (int i = 0; i < n; i++)
    {
        C.get();

        dist.push_back(make_pair(len(A,C), len(B,C)));
    }
    dist.push_back(make_pair(0,0));
    long long r1 = 0;
    long long r2 = 0;
    long long ans = 1e18;

    for (int i = 0; i <= n; i++)
    {
        r1 = dist[i].first;
        r2 = 0;
        for (int j = 0; j <= n; j++)
        {
            if (dist[j].second > r1)
            {
                r2 = max(r2, dist[j].second);
            }
        }
        ans = min(ans, r1 + r2);
    }

    cout << ans;

    return 0;
}


#include <iostream>
#include <cmath>
#include <vector>
#include <string>
using namespace std;

int a[100500];

struct Point
{
    long long x, y;

    Point (long long _x, long long _y) : x(_x), y(_y) {}
    Point () : x(), y() {}

    Point operator- (const Point &A)
    {
        return Point(x - A.x, y - A.y);
    }

    void get ()
    {
        cin >> x >> y;
    }

};

vector < pair <long long, long long> > dist;

long long len (Point A, Point B)
{
    return (A - B).x * (A - B).x + (A- B).y * (A -  B).y;
}

int main()
{
    int n;
    cin >> n;
    Point A,B;
    A.get(); B.get();

    Point C;

    for (int i = 0; i < n; i++)
    {
        C.get();

        dist.push_back(make_pair(len(A,C), len(B,C)));
    }
    dist.push_back(make_pair(0,0));
    long long r1 = 0;
    long long r2 = 0;
    long long ans = 1e18;

    for (int i = 0; i <= n; i++)
    {
        r1 = dist[i].first;
        r2 = 0;
        for (int j = 0; j <= n; j++)
        {
            if (dist[j].first > r1)
            {
                r2 = max(r2, dist[j].second);
            }
        }
        ans = min(ans, r1 + r2);
    }

    cout << ans;

    return 0;
}


#include <iostream>
#include <cmath>
#include <vector>
#include <string>
using namespace std;

int a[100500];

struct Point
{
    long long x, y;

    Point (long long _x, long long _y) : x(_x), y(_y) {}
    Point () : x(), y() {}

    Point operator- (const Point &A)
    {
        return Point(x - A.x, y - A.y);
    }

    void get ()
    {
        cin >> x >> y;
    }

};

vector < pair <long long, long long> > dist;

long long len (Point A, Point B)
{
    return (A - B).x * (A - B).x + (A- B).y * (A-B).y;
}

int main()
{
    int n;
    cin >> n;
    Point A,B;
    A.get(); B.get();

    Point C;

    for (int i = 0; i < n; i++)
    {
        C.get();

        dist.push_back(make_pair(len(A,C), len(B,C)));
    }
    dist.push_back(make_pair(0,0));
    long long r1 = 0;
    long long r2 = 0;
    long long ans = 1e18;

    for (int i = 0; i <= n; i++)
    {
        r1 = dist[i].first;
        r2 = 0;
        for (int j = 0; j < n; j++)
        {
            if (i != j)
            {
                r2 = max(r2, dist[j].second);
            }
        }

        ans = min(ans, r1 + r2);
    }

    cout << ans;

    return 0;
}


#include <iostream>
#include <cmath>
using namespace std;

int a[100500];

struct Point
{
    int x, y;

    Point (int _x, int _y) : x(_x), y(_y) {}
    Point () : x(), y() {}

    Point operator- (const Point &A)
    {
        return Point(x - A.x, y - A.y);
    }

    double len_to (const Point &A)
    {
        Point tmp = *this - A;
        return (sqrt(tmp.x * tmp.x + tmp.y * tmp.y));
    }
    void get ()
    {
        cin >> x >> y;
    }

};

struct Circle
{
    int x, y, r;

     void get ()
    {
        cin >> x >> y;
        r = 0;
    }

};

int len_P_P (Point A, Point B)
{
    Point tmp = A - B;

    return (tmp.x * tmp.x + tmp.y * tmp.y);
}

int len_to_cirlce (Circle A, Point B)
{
    Point one;
    one.x = A.x;
    one.y = A.y;
    return max(0, len_P_P(one, B) - A.r);
}

int main()
{
    int n;
    Circle X, Y;
    Point All[100500];
    cin >> n;
    X.get(); Y.get();

    for (int i = 0; i < n; i++)
    {
        All[i].get();
    }

    double ans = 0;

    for (int i = 0; i < n; i++)
    {
         int len1 = len_to_cirlce(X, All[i]);
         int len2 = len_to_cirlce(Y, All[i]);

         if (len1 < len2)
         {
            // cout << "r1 = ";
            X.r += len1;
           // cout << X.r << endl;
         }
         else
         {
            // cout << "r2 = " ;
            Y.r += len2;
           // cout << Y.r << endl;
         }
    }

    cout << X.r + Y.r;

    return 0;
}


#include <iostream>
#include <cmath>
#include <vector>
#include <string>
using namespace std;

int a[100500];

struct Point
{
    int x, y;

    Point (int _x, int _y) : x(_x), y(_y) {}
    Point () : x(), y() {}

    Point operator- (const Point &A)
    {
        return Point(x - A.x, y - A.y);
    }

    void get ()
    {
        cin >> x >> y;
    }

};

vector < pair <long long, long long> > dist;

long long len (Point A, Point B)
{
    return (A - B).x * (A - B).x + (A- B).y * (A-B).y;
}

int main()
{
    int n;
    cin >> n;
    Point A,B;
    A.get(); B.get();

    Point C;

    for (int i = 0; i < n; i++)
    {
        C.get();

        dist.push_back(make_pair(len(A,C), len(B,C)));
    }
    dist.push_back(make_pair(0,0));

    long long r1 = 0;
    long long r2 = 0;
    long long mx = 0;
    long long ans = 1e18;

    for (int i = 0; i <= n; i++)
    {
        r1 = dist[i].first;
        r2 = 0;
        for (int j = 0; j <= n; j++)
        {
            if (i != j)
            {
                r2 = max(r2, dist[j].second);
            }
        }

        ans = min(ans, r1 + r2);
    }

    cout << ans;

    return 0;
}


#include <iostream>
#include <cmath>
using namespace std;

int a[100500];

struct Point
{
    int x, y;

    Point (int _x, int _y) : x(_x), y(_y) {}
    Point () : x(), y() {}

    Point operator- (const Point &A)
    {
        return Point(x - A.x, y - A.y);
    }

    double len_to (const Point &A)
    {
        Point tmp = *this - A;
        return (sqrt(tmp.x * tmp.x + tmp.y * tmp.y));
    }
    void get ()
    {
        cin >> x >> y;
    }

};

struct Circle
{
    int x, y, r;

     void get ()
    {
        cin >> x >> y;
        r = 0;
    }

};

int len_P_P (Point A, Point B)
{
    Point tmp = A - B;

    return (tmp.x * tmp.x + tmp.y * tmp.y);
}

int len_to_cirlce (Circle A, Point B)
{
    Point one;
    one.x = A.x;
    one.y = A.y;
    return max(0, len_P_P(one, B) * len_P_P(one,B) - A.r * A.r);
}

int main()
{
    int n;
    Circle X, Y;
    Point All[100500];
    cin >> n;
    X.get(); Y.get();

    for (int i = 0; i < n; i++)
    {
        All[i].get();
    }

    double ans = 0;

    for (int i = 0; i < n; i++)
    {
         int len1 = len_to_cirlce(X, All[i]);
         int len2 = len_to_cirlce(Y, All[i]);

         if (len1 < len2)
         {
             //cout << "1" << endl;
            X.r += sqrt(len1);
         }
         else
         {
            // cout << "2 ";
            // cout << len2 << endl;
            Y.r += sqrt(len2);
         }
    }

    cout << X.r  + Y.r;

    return 0;
}


#include <iostream>
#include <cmath>
using namespace std;

int a[100500];

struct Point
{
    int x, y;

    Point (int _x, int _y) : x(_x), y(_y) {}
    Point () : x(), y() {}

    Point operator- (const Point &A)
    {
        return Point(x - A.x, y - A.y);
    }

    void get ()
    {
        cin >> x >> y;
    }

};

struct Circle
{
    int x, y;
    long long r;

     void get ()
    {
        cin >> x >> y;
        r = 0;
    }

};

long long p_to_p (Point A, Point B)
{
    Point tmp = A - B;
    return (tmp.x * tmp.x + tmp.y * tmp.y);
}

long long len (Circle A, Point B)
{
    Point tmp;
    tmp.x = A.x;
    tmp.y = A.y;

    return max(0 * 1ll, p_to_p(tmp, B));

}

int main()
{
    int n;
    Circle X, Y;
    Point All[100500];
    cin >> n;
    X.get(); Y.get();

    for (int i = 0; i < n; i++)
    {
        All[i].get();
    }

    double ans = 0;

    for (int i = 0; i < n; i++)
    {
         long long len1 = len(X, All[i]);
         long long len2 = len(Y, All[i]);

         if (len1 < X.r)
            continue;
         if (len2 < Y.r)
            continue;

         long long r1 = len1 + Y.r;
         long long r2 = X.r + len2;

         if (r1 < r2)
         {
            X.r = len1;
         }
         else
         {
            Y.r = (len2);
         }
    }

    cout <<  X.r + Y.r;

    return 0;
}


#include <iostream>
#include <cmath>
using namespace std;

int a[100500];

struct Point
{
    int x, y;

    Point (int _x, int _y) : x(_x), y(_y) {}
    Point () : x(), y() {}

    Point operator- (const Point &A)
    {
        return Point(x - A.x, y - A.y);
    }

    double len_to (const Point &A)
    {
        Point tmp = *this - A;
        return (sqrt(tmp.x * tmp.x + tmp.y * tmp.y));
    }
    void get ()
    {
        cin >> x >> y;
    }

};

struct Circle
{
    int x, y, r;

     void get ()
    {
        cin >> x >> y;
        r = 0;
    }

};

double len_P_P (Point A, Point B)
{
    Point tmp = A - B;

    return (tmp.x * tmp.x + tmp.y * tmp.y);
}

int len_to_cirlce (Circle A, Point B)
{
    Point one;
    one.x = A.x;
    one.y = A.y;
    return max(0.0, floor(len_P_P(one, B) - A.r));
}

int main()
{
    int n;
    Circle X, Y;
    Point All[100500];
    cin >> n;
    X.get(); Y.get();

    for (int i = 0; i < n; i++)
    {
        All[i].get();
    }

    double ans = 0;

    for (int i = 0; i < n; i++)
    {
         int len1 = len_to_cirlce(X, All[i]);
         int len2 = len_to_cirlce(Y, All[i]);

         if (len1 < len2)
         {
            // cout << "r1 = ";
            X.r += len1;
           // cout << X.r << endl;
         }
         else
         {
            // cout << "r2 = " ;
            Y.r += len2;
           // cout << Y.r << endl;
         }
    }

    cout << X.r + Y.r;

    return 0;
}


#include <iostream>
#include <cmath>
using namespace std;

int a[100500];

struct Point
{
    int x, y;

    Point (int _x, int _y) : x(_x), y(_y) {}
    Point () : x(), y() {}

    Point operator- (const Point &A)
    {
        return Point(x - A.x, y - A.y);
    }

    void get ()
    {
        cin >> x >> y;
    }

};

struct Circle
{
    int x, y;
    long long r;

     void get ()
    {
        cin >> x >> y;
        r = 0;
    }

};

long long p_to_p (Point A, Point B)
{
    Point tmp = A - B;
    return (tmp.x * tmp.x + tmp.y * tmp.y);
}

long long len (Circle A, Point B)
{
    Point tmp;
    tmp.x = A.x;
    tmp.y = A.y;

    return max(0 * 1ll, p_to_p(tmp, B) - A.r);

}

int main()
{
    int n;
    Circle X, Y;
    Point All[100500];
    cin >> n;
    X.get(); Y.get();

    for (int i = 0; i < n; i++)
    {
        All[i].get();
    }

    double ans = 0;

    for (int i = 0; i < n; i++)
    {
         long long len1 = len(X, All[i]);
         long long len2 = len(Y, All[i]);

         long long r1 = abs((X.r + len1)*(X.r + len1)) + abs(Y.r * Y.r);
         double r2 = abs(X.r * X.r) + abs((Y.r + len2)*(Y.r + len2));

         if (r1 < r2)
         {
            X.r += len1;
         }
         else
         {
            Y.r += (len2);
         }
    }

   // cout << abs(X.r * X.r) << " " << abs (Y.r * Y.r) << endl;

    cout <<  X.r + Y.r;

    return 0;
}


#include <bits/stdc++.h>

using namespace std;

const int N = 100100;

int a[N];

int GCD(int x,int y){
    return y ? GCD(y,x%y) : x;
}

int main()
{
    int n;  cin>>n;

    int G = 0;

    for(int i=0;i<n;i++)    scanf("%d",a+i) , G = GCD(G,a[i]);

    cout << G << endl;

    for(int i=0;i<n;i++)
        if(G%a[i]==0)
            return 0*printf("%d",a[i]);

    printf("-1");
}


#include <bits/stdc++.h>

using namespace std;

const int N = 100100;

int a[N];

int GCD(int x,int y){
    return y ? GCD(y,x%y) : x;
}

int main()
{
    int n;  cin>>n;

    int G = 0;

    for(int i=0;i<n;i++)    scanf("%d",a+i) , G = GCD(G,a[i]);

    for(int i=0;i<n;i++)
        if(G%a[i]==0)
            return 0*printf("%d",a[i]);

    printf("-1");
}


#include <bits/stdc++.h>

using namespace std;

const int N = 100100;

int a[N];

int GCD(int x,int y){
    return y ? GCD(y,x%y) : 0;
}

int main()
{
    int n;  cin>>n;

    int G = 0;

    for(int i=0;i<n;i++)    scanf("%d",a+i) , G = GCD(G,a[i]);

    for(int i=0;i<n;i++)
        if(G%a[i]==0)
            return 0*printf("%d",a[i]);

    printf("-1");
}


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

int main(){
    int n;
    cin>>n;
    int arr[n];
    sort(arr,arr+n);
    for(int i = 0 ; i < n ; i++){
        if(arr[i]%arr[0]!=0){
            cout<<-1;
            return 0;
        }
    }
    cout<<arr[0];
}


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

int main(){
    int n;
    cin>>n;
    int arr[n];
    for(int i = 0 ; i < n ; i++)
        cin>>arr[i];
    sort(arr,arr+n);
    for(int i = 0 ; i < n ; i++){
        if(arr[i]%arr[0]!=0){
            cout<<-1;
            return 0;
        }
    }
    cout<<arr[0];
}


     #include<bits/stdc++.h>
using namespace std;
//created by:Suryaraj Bhaduri
#define int long long
#define ld long double
#define pb emplace_back
#define rep(i,x,n) for(int i=x;i<n;i++)
#define ford(i,x,n) for(int i=x;i<=n;i++)
#define tr(it,c) for(auto it=c.begin();it!=c.end();it++)
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<double> vd;
typedef map<int,int> mii;
#ifndef FAST_IO
 #define IOS ios_base::sync_with_stdio(false);cin.tie(NULL)
#endif
template< class T > void print(T t){for(auto &it:t)cout<<it<<" ";cout<<"\n";}
template< class T > T _abs(T n) { return (n < 0 ? -n : n); }
template< class T > T _max(T a, T b) { return (!(a < b) ? a : b); }
template< class T > T _min(T a, T b) { return (a < b ? a : b); }
template< class T > T gcd(T a, T b) { return (b != 0 ? gcd<T>(b, a%b) : a); }
template< class T > T lcm(T a, T b) { return (a / gcd<T>(a, b) * b); }
template< class T > bool inside(T a, T b, T c) { return a<=b && b<=c; }
const int MAXN=1e5+4;
int a[MAXN];
void solve(){
    int n;
    cin>>n;
    for(int i=0;i<n;i++)cin>>a[i];
    int ans=a[0];
    for(int i=0;i<n;i++){
        ans=gcd(ans,a[i]);
    }
    cout<<((ans==1)?"-1":to_string(ans))<<endl;
}
int32_t main(){
	IOS;
	#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
	#endif
	solve();
	#ifdef LOCAL_DEFINE
	cerr<<"time elapsed "<<(double)clock()/CLOCKS_PER_SEC<<endl;
	#endif
}


     #include<bits/stdc++.h>
using namespace std;
//created by:Suryaraj Bhaduri
#define int long long
#define ld long double
#define pb emplace_back
#define rep(i,x,n) for(int i=x;i<n;i++)
#define ford(i,x,n) for(int i=x;i<=n;i++)
#define tr(it,c) for(auto it=c.begin();it!=c.end();it++)
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<double> vd;
typedef map<int,int> mii;
#ifndef FAST_IO
 #define IOS ios_base::sync_with_stdio(false);cin.tie(NULL)
#endif
template< class T > void print(T t){for(auto &it:t)cout<<it<<" ";cout<<"\n";}
template< class T > T _abs(T n) { return (n < 0 ? -n : n); }
template< class T > T _max(T a, T b) { return (!(a < b) ? a : b); }
template< class T > T _min(T a, T b) { return (a < b ? a : b); }
template< class T > T gcd(T a, T b) { return (b != 0 ? gcd<T>(b, a%b) : a); }
template< class T > T lcm(T a, T b) { return (a / gcd<T>(a, b) * b); }
template< class T > bool inside(T a, T b, T c) { return a<=b && b<=c; }
const int MAXN=1e5+4;
int a[MAXN];
void solve(){
    int n;
    cin>>n;
    for(int i=0;i<n;i++)cin>>a[i];
    int ans=a[0];
    for(int i=0;i<n;i++){
        ans=gcd(ans,a[i]);
    }
    cout<<ans<<endl;
}
int32_t main(){
	IOS;
	#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
	#endif
	solve();
	#ifdef LOCAL_DEFINE
	cerr<<"time elapsed "<<(double)clock()/CLOCKS_PER_SEC<<endl;
	#endif
}


     #include<bits/stdc++.h>
using namespace std;
//created by:Suryaraj Bhaduri
#define int long long
#define ld long double
#define pb emplace_back
#define rep(i,x,n) for(int i=x;i<n;i++)
#define ford(i,x,n) for(int i=x;i<=n;i++)
#define tr(it,c) for(auto it=c.begin();it!=c.end();it++)
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<double> vd;
typedef map<int,int> mii;
#ifndef FAST_IO
 #define IOS ios_base::sync_with_stdio(false);cin.tie(NULL)
#endif
template< class T > void print(T t){for(auto &it:t)cout<<it<<" ";cout<<"\n";}
template< class T > T _abs(T n) { return (n < 0 ? -n : n); }
template< class T > T _max(T a, T b) { return (!(a < b) ? a : b); }
template< class T > T _min(T a, T b) { return (a < b ? a : b); }
template< class T > T gcd(T a, T b) { return (b != 0 ? gcd<T>(b, a%b) : a); }
template< class T > T lcm(T a, T b) { return (a / gcd<T>(a, b) * b); }
template< class T > bool inside(T a, T b, T c) { return a<=b && b<=c; }
const int MAXN=1e5+4;
void solve(){
    int n;
    cin>>n;
    vi a(n);
    for(int i=0;i<n;i++)cin>>a[i];
    int ans=a[0];
    sort(a.begin(),a.end());
    for(int i=0;i<n;i++){
        ans=gcd(ans,a[i]);
    }

    cout<<(!(binary_search(a.begin(),a.end(),ans))?"-1":to_string(ans))<<endl;
}
int32_t main(){
	IOS;
	#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
	#endif
	solve();
	#ifdef LOCAL_DEFINE
	cerr<<"time elapsed "<<(double)clock()/CLOCKS_PER_SEC<<endl;
	#endif
}


#include <bits/stdc++.h>

using namespace std;

int n, a[100005], c;

int main ()
{
	ios_base::sync_with_stdio(0);
	cin.tie(NULL);
	cin >> n;
	for (int i = 1; i <= n; ++i)
	{
		cin >> a[i];
	}
	sort (a + 1, a + 1 + n);
	for (int i = 1; i <= n; ++i)
	{
		for (int j = 1; j <= n; ++j)
		{
			if (a[j] % a[i] == 0 && i!=j)
			{
				++c;
			}
		}
		if (c == n-1)
		{
			cout << a[i];
			return 0;
		}
		c = 0;
	}
	cout << "-1";
	return 0;
}


#include <bits/stdc++.h>

using namespace std;

int n, a[100005], c, mn=1000000005, id;

int main ()
{
	ios_base::sync_with_stdio(0);
	cin.tie(NULL);
	cin >> n;
	for (int i = 1; i <= n; i++)
	{
		cin >> a[i];
		if (a[i] < mn)
		{
			mn = a[i];
			id = i;
		}
	}
	for (int i = 1; i <= n; i++)
	{
		if (a[i] % mn == 0 && i != id)
		{
			c++;
		}
	}
	if (c == n - 1)
	{
		cout << mn;
	}
	else {
		cout << "-1";
	}
	return 0;
}


#include <bits/stdc++.h>

using namespace std;

int n, a[100005], c;

int main ()
{
	cin >> n;
	for (int i = 1; i <= n; i++)
	{
		cin >> a[i];
	}
	sort (a + 1, a + 1 + n);
	for (int i = 1; i <= n; i++)
	{
		for (int j = 1; j <= n; j++)
		{
			if (a[j] % a[i] == 0 && i!=j)
			{
				c ++;
			}
		}
		if (c == n-1)
		{
			cout << a[i];
			return 0;
		}
		c = 0;
	}
	cout << "-1";
	return 0;
}


#include <stdio.h>
#include <string.h>
#include <algorithm>
#include<iostream>
using namespace std;
const int maxn = 100005;
int a[maxn];
int main()
{
	int m=0x3f3f3f3f;
	int n;
	cin>>n;
	int i,a[1000];
	for(i=0;i<n;i++)
	{
		cin>>a[i];
 	    m=min(a[i],m);
	}
	int T=1;
	for(int i = 0; i < n; i++)
    {
        if(a[i]%m!=0)
        {
            T=0;
        	break;
        }
    }
    if(T)
        cout<<m<<endl;
    else
        cout<<"-1"<<endl;
    return 0;
}


#include<iostream>
#include <stdio.h>
#include <string.h>
#include <algorithm>
using namespace std;
const int maxn = 100005;
int a[maxn];
int m=100000000;
int main()
{
	int t,f;
	int n;
	cin>>n;
	int i,a[1000];
	for(i=0;i<n;i++)
	{
		cin>>a[i];
 	    m=min(a[i],m);
 	}
	for(i=0;i<n;i++)
	{
		if(a[i]%m==0)
		t++;
		else
		{
			cout<<"-1"<<endl;
			break;
		}
	}
	if(t==n)
	cout<<m<<endl;
	return 0;
}


#include<iostream>
#include <stdio.h>
#include <string.h>
#include <algorithm>
using namespace std;
const int maxn = 100005;
int a[maxn];
int m=0x3f3f3f3f;
int main()
{
	int T;
	int n;
	cin>>n;
	int i,a[1000];
	for(i=0;i<n;i++)
	{
		cin>>a[i];
 	    m=min(a[i],m);
	}
	for(int i = 0; i < n; i++)
    {
        if(a[i]%m!=0)
        {
            T=0;
        	break;
        }
    }
    if(T)
        cout<<m<<endl;
    else
        cout<<"-1"<<endl;
    return 0;
}


#include<iostream>
#include <stdio.h>
#include <string.h>
#include <algorithm>
using namespace std;
const int maxn = 100005;
int a[maxn];
int m=0x3f3f3f3f;
int main()
{
	int t;
	int n;
	cin>>n;
	int i,a[1000];
	for(i=0;i<n;i++)
	{
		cin>>a[i];
 	    m=min(a[i],m);
 	}
	for(i=0;i<n;i++)
	{
		if(a[i]%m==0)
		t++;
		else
		{
			cout<<"-1"<<endl;
			break;
		}
	}
	if(t==n)
	cout<<m<<endl;
	return 0;
}


#include <stdio.h>
#include <string.h>
#include <algorithm>

using namespace std;
const int maxn = 100005;
int a[maxn];

int main()
{
    int n;
    while (scanf("%d", &n) != EOF)
    {
        int m = 0x3f3f3f3f;
        for (int i = 0; i < n; i++)
        {
            scanf("%d", &a[i]);
            m = min(a[i], m);
        }
        int f = 1;
        for (int i = 0; i < n; i++)
        {
            if (a[i]%m != 0)
            {
                f = 0;
                break;
            }
        }
        if (f)
            printf("%d\n", m);
        else
            puts("-1");
    }
    return 0;
}


#include<iostream>
#include <stdio.h>
#include <string.h>
#include <algorithm>
using namespace std;
const int maxn = 100005;
int a[maxn];
int m=100000000;
int main()
{
	int n;
	cin>>n;
	int i,a[1000];
	for(i=0;i<n;i++)
	{
		cin>>a[i];
 	    m=min(a[i],m);
 	}
	for(i=0;i<n;i++)
	{
		if(a[i]%m==0)
		{
		cout<<m<<endl;
		break;
		}
		else
		cout<<"-1"<<endl;
	}
	return 0;
}


#include<iostream>
#include <stdio.h>
#include <string.h>
#include <algorithm>
using namespace std;
const int maxn = 100005;
int a[maxn];
int m=0x3f3f3f3f;
int main()
{
	int T=1;
	int n;
	cin>>n;
	int i,a[1000];
	for(i=0;i<n;i++)
	{
		cin>>a[i];
 	    m=min(a[i],m);
	}
	for(int i = 0; i < n; i++)
    {
        if(a[i]%m!=0)
        {
            T=0;
        	break;
        }
    }
    if(T)
        cout<<m<<endl;
    else
        cout<<"-1"<<endl;
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll a[(int)1e5+5];
int main()
{
	ll n,ans=1,tmp;
	cin>>n;
	for(int i=1;i<=n;i++)
		cin>>a[i];
	sort(a+1,a+n+1);
	ans=a[1];
	for(int i=2;i<=n;i++)
	{
		if(a[i]%ans!=0)
		{
			ans=-1;
			break;
		}
	}
	cout<<ans<<endl;
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
	ll n,ans=1,tmp;
	cin>>n;
	while(n--)
	{
		cin>>tmp;
//		ans=ans*tmp/__gcd(ans,tmp);
	}
	cout<<1<<endl;
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
    vector<int>v1;
    std::ios::sync_with_stdio(false);
    int n,cnt=0,flag=0,s;
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>s;
        v1.push_back(s);
    }
    sort(v1.begin(),v1.end());
    int stp=v1[0];
    cnt=0;
    for(int j=0;j<n;j++){
        if(v1[j]%stp==0) cnt++;
    }
    if(cnt==n){
        cout<<stp;
        }
    else
        cout<<"-1";
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int a[2005];
int main()
{
    std::ios::sync_with_stdio(false);
    int n,sum=0,flag=0,s,sum1=0;
    cin>>n;
    s=2*n;
    for(int i=0;i<s;i++){
        cin>>a[i];
        sum+=a[i];
        if(i<n){
            sum1+=a[i];
        }
    }
    if(sum%2==1){
        for(int i=0;i<s;i++){
            cout<<a[i]<<" ";
        }
    }
    else{
        if(sum1!=(sum-sum1)){
            for(int i=0;i<s;i++){
                cout<<a[i]<<" ";
            }
        }
        else{
            for(int i=0;i<n;i++){
                for(int j=n;j<s;j++){
                    if(a[i]!=a[j]){
                        swap(a[i],a[j]);
                        flag=1;
                        break;
                    }
                }
                if(flag==1) break;
            }
            if(flag==1){
                for(int i=0;i<s;i++){
                    cout<<a[i]<<" ";
                    }
            }
            else{
                cout<<"-1";
            }
        }
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
    vector<int>v1;
    std::ios::sync_with_stdio(false);
    int n,cnt=0,flag=0,s;
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>s;
        v1.push_back(s);
    }
    sort(v1.begin(),v1.end());
    for(int i=0;i<n;i++){
        int stp=v1[i];
        cnt=0;
        for(int j=0;j<n;j++){
            if(v1[j]%stp==0) cnt++;
        }
        if(cnt==n){
            cout<<stp;
            flag=1;
            break;
        }
    }
    if(flag==0)
        cout<<"-1";
    return 0;
}


#include<cstdio>
#include<algorithm>
#define maxn 10005
using namespace std;
int a[maxn];
int n,Gcd;
bool flag=0;
int gcd(int a, int b){
	if(b==0) return a;
	else return gcd(b,a%b);
}
int main(){
	scanf("%d",&n);
	scanf("%d",&a[1]);
	Gcd=a[1];
	for(int i=2; i<=n; i++){
	    scanf("%d",&a[i]);
	    Gcd=gcd(Gcd,a[i]);
    }
    for(int i=1; i<=n; i++)
    	if(Gcd%a[i]==0){
    		flag=1;
    		printf("%d",a[i]);
    		break;
		}
	if(flag==0) printf("-1");
	return 0;
}


#include<cstdio>
#include<algorithm>
#define maxn 100005
using namespace std;
int a[maxn];
int n,Gcd;
bool flag=0;
int gcd(int a, int b){
	if(b==0) return a;
	else return gcd(b,a%b);
}
int main(){
	scanf("%d",&n);
	scanf("%d",&a[1]);
	Gcd=a[1];
	for(int i=2; i<=n; i++){
	    scanf("%d",&a[i]);
	    Gcd=gcd(Gcd,a[i]);
    }
    for(int i=1; i<=n; i++)
    	if(Gcd%a[i]==0){
    		flag=1;
    		printf("%d",a[i]);
    		break;
		}
	if(flag==0) printf("-1");
	return 0;
}
//gcdÕ·×ªÏà³ý·¨


#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin >> n;
    long long int mi=1000000000000;
    long long int a[20000];
    for (int i=1;i<=n;i++)
    {
        cin >> a[i];
        mi=min(mi,a[i]);
    }
    for (int i=1;i<=n;i++)
    if (a[i]%mi>0){cout << -1;return 0;}
    cout << mi;
return 0;
}


#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin >> n;
    int mi=1e9;
    int a[100010];
    for (int i=1;i<=n;i++)
    {
        cin >> a[i];
        mi=min(mi,a[i]);
    }
    for (int i=1;i<=n;i++)
    if (a[i]%mi==1){cout << -1;return 0;}
    cout << mi;
return 0;
}


#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin >> n;
    long long int mi=10000000000;
    long long int a[100100];
    for (int i=1;i<=n;i++)
    {
        cin >> a[i];
        mi=min(mi,a[i]);
    }
    for (int i=1;i<=n;i++)
    if (a[i]%mi>0){cout << -1;return 0;}
    cout << mi;
return 0;
}


#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin >> n;
    long long int mi=1000000000000;
    long long int a[20000];
    for (int i=1;i<=n;i++)
    {
        cin >> a[i];
        mi=min(mi,a[i]);
    }
    for (int i=1;i<=n;i++)
    if (a[i]%mi==1){cout << -1;return 0;}
    cout << mi;
return 0;
}


#include<cstdio>
#include<iostream>
using namespace std;
int n,m,w[5000],ans=9999999;
int main()
{
   int i;
   scanf("%d",&n);
   for(i=1;i<=n;i++){
      scanf("%d",&w[i]);
      ans = min(ans,w[i]);
   }
   for(i=1;i<=n;i++){
      if(w[i]%ans != 0){
         ans = -1;
         break;
      }
   }
   printf("%d",ans);
   return 0;
}


#include<iostream>
#include<cstring>
using namespace std;
#define N 100050
int n,a[N];
inline int min(int a,int b){return a<b;}
int main()
{
  ios::sync_with_stdio(false);
  int i,ans=94949494;
  cin>>n;
  for(i=1;i<=n;i++){cin>>a[i];ans=min(ans,a[i]);}
  for(i=1;i<=n;i++)
    if(a[i]%ans!=0){cout<<"-1"<<endl;return 0;}
  cout<<ans<<endl;
}


#include<iostream>
#include<fstream>
#include<algorithm>
#include<cmath>
#include<cstdlib>
#include<cstring>
#include<vector>
using namespace std;
int n,a[100005],gcd;
int main()
{
    cin>>n;
    for(int i=1;i<=n;i++) scanf("%d",&a[i]);
    gcd=a[1];
    for(int i=1;i<=n;i++) gcd=__gcd(gcd,a[i]);
    for(int i=1;i<=n;i++)
    {
        if(a[i]==gcd)
        {
            cout<<a[i];
            return 0;
        }
    }
    cout<<-1;
    return 0;
}


#include<iostream>
#include<stdio.h>
#include<stdlib.h>
#include<algorithm>
using namespace std;
int a[1000001];
bool cmp(int a,int b)
{
    return a<b;
}
int main()
{
    int n;
    scanf("%d",&n);
    register int i;
    for(i=1;i<=n;++i)
        scanf("%lld",&a);
    sort(a+1,a+1+n,cmp);
    int k=a[1];
    for(i=1;i<=n;++i)
    {
        if(a[i]%k!=0)
        {
            printf("-1");
            return 0;
        }
    }
    printf("%lld",k);
    return 0;
}


#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
#include<cmath>
using namespace std;
long long n,a[100005],s=1;
int main()
{
//	freopen(".in","r",stdin);
//	freopen(".out","w",stdout);
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		scanf("%lld",&a[i]);
	}
	s=a[1];
	for(int i=2;i<=n;i++){
		s=__gcd(a[i],s);
	}
	for(int i=1;i<=n;i++) if(s==a[i]){
		cout<<a[i];
		return 0;
	}
	cout<<-1;
	return 0;
}


// luogu-judger-enable-o2
#include<cstdio>
using namespace std;
int n,m,w[100010],ans=100000010;
int MIN(int x,int y){ return x > y ? y : x; }
inline void read(int& ret) {
    ret=0;int f=1;char ch=getchar();
    while (ch<'0'||ch>'9') {if (ch=='-') f=-f;ch=getchar();}
    while (ch>='0'&&ch<='9') ret=ret*10+ch-'0',ch=getchar();
    ret*=f;
}
int main()
{
   int i;
   read(n);
   for(i=1;i<=n;i++){
      read(w[i]);
      ans = MIN(ans,w[i]);
   }
   for(i=1;i<=n;i++){
      if(w[i]%ans != 0){
         printf("1\n");
         return 0;
      }
   }
   printf("%d\n",ans);
   return 0;
}


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

int n,a[100010],ans;

int gcd(int x,int y){
	if(y==0)
		return x;
	return gcd(y,x%y);
}

int main(){
	cin>>n>>a[1];
	ans=a[1];
	for(int i=2;i<=n;i++){
		cin>>a[i];
		ans=gcd(ans,a[i]);
	}
	for(int i=1;i<=n;i++)
		if(a[i]==ans){
			cout<<ans;
			return 0;
		}
	cout<<-1;
	return 0;
}


// luogu-judger-enable-o2
#include<cstdio>
#include<cctype>
#define ri register int
using namespace std;
inline void read(int& ret) {
    ret=0;int f=1;char ch=getchar();
    while (ch<'0'||ch>'9') {if (ch=='-') f=-f;ch=getchar();}
    while (ch>='0'&&ch<='9') ret=ret*10+ch-'0',ch=getchar();
    ret*=f;
}
template <typename T>inline void redi(T& t)
{
    ri c=getchar();t=0;
    while(!isdigit(c))c=getchar();
    while(isdigit(c))t=t*10+c-48,c=getchar();
}
template <typename T,typename... Args> inline void redi(T& t, Args&... args)
{
    redi(t);redi(args...);
}
int MIN(int x,int y) { return x > y ? y : x ; }
int main()
{
   int n,i,w[100010],ans=1000010;
   redi(n);
   for(i=1;i<=n;i++)
   {
      redi(w[i]);
      ans = MIN(ans,w[i]);
   }
   for(i=1;i<=n;i++)
   {
      if(w[i]%ans != 0){
         printf("-1");
         break;
      }
   }
   printf("%d",ans);
}


#include<bits/stdc++.h>
using namespace std;
int n,i,a[100005],gcd;
int main(){
	cin>>n;
	for(i=1;i<=n;i++){
		cin>>a[i];
	}
	gcd=a[1];
	for(i=2;i<=n;i++){
		gcd=__gcd(gcd,a[i]);
	}
	for(i=1;i<=n;i++){
		if(a[i]==gcd){
			cout<<a[i];
			return 0;
		}
	}
	cout<<-1;
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
int main()
{
    long long int a,b,m,j,t,i,k,ar[100006],n,x,c,d;
    cin >> a ;
    m=9999999999;
    for(i=1; i<=a; i++)
    {
        cin >> ar[i];
        m = min(m,ar[i]);
    }
    for(i=1; i<=a; i++)
        if(ar[i]%m!=0)
        {
            cout << "-1" << endl;
            return 0;
        }
    cout << m << endl;
}


#include <bits/stdc++.h>
using namespace std;
int main()
{
    long long int a,b,m,j,t,i,k,ar[100006],n,x,c,d;
    cin >> a ;
    m=999999999;
    for(i=1; i<=a; i++)
    {
        cin >> ar[i];
        m = min(m,ar[i]);
    }
    for(i=1; i<=a; i++)
        if(ar[i]%m!=0)
        {
            cout << "-1" << endl;
            return 0;
        }
    cout << m << endl;
}


#include <bits/stdc++.h>
using namespace std;
int main()
{
    long long int a,b,m,j,t,i,k,ar[100006],n,x,c,d;
    cin >> a ;
    m=12345678;
    for(i=1; i<=a; i++)
    {
        cin >> ar[i];
        m = min(m,ar[i]);
    }
    for(i=1; i<=a; i++)
        if(ar[i]%m!=0)
        {
            cout << "-1" << endl;
            return 0;
        }
    cout << m << endl;
}


///                         .
///                     /   ))     |\         )               ).
///               c++. (\  ( `.    / )  (\   ( `.     ).     ( (
///               | |   ))  ) )   ( (   `.`.  ) )    ( (      ) )
///               | |  ( ( / _..----.._  ) | ( ( _..----.._  ( (
/// ,-.           | |---) V.'-------.. `-. )-/.-' ..------ `--) \._
/// | /===========| |  (   |      ) ( ``-.`\/'.-''           (   ) ``-._
/// | | / / / / / | |--------------------->  <-------------------------_>=-
/// | \===========| |                 ..-'./\.`-..                _,,-'
/// `-'           | |-------._------''_.-'----`-._``------_.-----'
///               | |         ``----''            ``----''
///               | |
///               c++`

///██╗ ██████╗ ██╗    ██████╗  ██████╗  ██████╗   ██████╗
///██║██╔═══██╗██║    ╚════██╗██╔═████╗ ╚════██╗ ██╔═████╗
///██║██║   ██║██║     █████╔╝██║██╔██║  █████╔╝ ██║██╔██║
///██║██║   ██║██║    ██╔═══╝ ████╔╝██║ ██╔═══╝  ████╔╝██║
///██║╚██████╔╝██║    ███████╗╚██████╔╝ ███████╗ ╚██████╔╝
///╚═╝ ╚═════╝ ╚═╝    ╚══════╝ ╚═════╝  ╚══════╝  ╚═════╝

#include<bits/stdc++.h>
#include<fstream>
#define ll long long
#define ld long double
#define pb push_back
#define pf push_front
#define fr first
#define sc second
#define mlojins cout.tie(NULL);
#define bzbz cin.tie(NULL);
#define CODER ios_base::sync_with_stdio(0)  ;
#define p_b pop_back
#define p_f pop_front
#define Qulukh
#define Zohiri_dzd
#define Mekh
#define Black_star
#define Kaskelen_Vividish
#define come_from_tajikistan
#define Ghestkiy_500
using namespace std ;

const ll N = 1e6 + 1;

map <ll , ll> mp , pm ;
deque <ll> v , vc , ve ,vv , vd ;
deque <char> p , pe ;
deque <string> ts , ss , st ;
deque <double> sd , ds ;
ll a , b , c , d , e , f , cnt , ans , r , n , l , x , y ;
ld q , t , cnt1 , cnt2 ;
string g , h , w , o , m , s ;
char z , u ;
bool re , rt ;
vector<pair < ll , ll > > pr , rp , pp ;
map <pair< ll , ll > , ll > aw , wa ;
int main ()
{
    bzbz
    mlojins
    Qulukh
    Mekh
    CODER
    Ghestkiy_500
    Zohiri_dzd
    Black_star
    Kaskelen_Vividish
    come_from_tajikistan
    ///freopen("input.txt" , "r" , stdin );
    ///freopen("output.txt", "w" , stdout );
    ///Author :: Murtazoev Alijon
    cin >> a ;
    for (ll i = 0 ; i < a ; i ++ )
    {
        cin >> b ;
        v.pb(b) ;
        vc.pb(b) ;
    }
    sort(vc.begin() , vc.end()) ;
    for (ll i = 0 ; i < v.size() ; i ++ )
    {
        if (v[i] % vc[0] == 0)
            cnt ++ ;
    }
    if (cnt == v.size())
    {
        cout << vc[0] ;
    }
    else
        cout << -1 ;
}
///Mmavl studios
///Eco students


////██╗ ██████╗ ██╗    ██████╗  ██████╗  ██╗ █████╗
////██║██╔═══██╗██║    ╚════██╗██╔═████╗███║██╔══██╗
////██║██║   ██║██║     █████╔╝██║██╔██║╚██║╚██████║
////██║██║   ██║██║    ██╔═══╝ ████╔╝██║ ██║ ╚═══██║
////██║╚██████╔╝██║    ███████╗╚██████╔╝ ██║ █████╔╝
////╚═╝ ╚═════╝ ╚═╝    ╚══════╝ ╚═════╝  ╚═╝ ╚════╝

#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define pb push_back
#define pf push_front
#define fr first
#define sc second
#define mlojins cout.tie(NULL);
#define bzbz cin.tie(NULL);
#define CODER ios_base::sync_with_stdio(0)  ;
#define p_b pop_back
#define p_f push_front

using namespace std ;

map <ll , ll> mp , pm ;
vector <ll> v , vc , ve ;
deque <ll> p , pe ;
ll a , b , c , d , e , f , cnt , ans , r , n ;
float q , t , cnt1;
string g , h , w , o , z , m ;
char y , u ;
int main ()
{
    bzbz
    mlojins
    CODER
    cin >> a ;
    for (int i = 0 ; i < a ; i ++ )
    {
        cin >> b ;
        v.pb(b);
    }
    sort(v.begin() , v.end());
    for (int i = 0 ; i < a ; i ++ )
    {
        cnt = v[i] ;
        ans = 0 ;
        for (int j = 0 ; j < a ; j ++ )
        {
            if (v[j] % cnt == 0)
                ans ++ ;
        }
        if (ans == v.size())
        {
            cout << cnt ;
            return 0 ;
        }
    }
    cout << -1 ;
}


////██╗ ██████╗ ██╗    ██████╗  ██████╗  ██╗ █████╗
////██║██╔═══██╗██║    ╚════██╗██╔═████╗███║██╔══██╗
////██║██║   ██║██║     █████╔╝██║██╔██║╚██║╚██████║
////██║██║   ██║██║    ██╔═══╝ ████╔╝██║ ██║ ╚═══██║
////██║╚██████╔╝██║    ███████╗╚██████╔╝ ██║ █████╔╝
////╚═╝ ╚═════╝ ╚═╝    ╚══════╝ ╚═════╝  ╚═╝ ╚════╝

#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define pb push_back
#define pf push_front
#define fr first
#define sc second
#define mlojins cout.tie(NULL);
#define bzbz cin.tie(NULL);
#define CODER ios_base::sync_with_stdio(0)  ;
#define p_b pop_back
#define p_f push_front

using namespace std ;

map <ll , ll> mp , pm ;
vector <ll> v , vc , ve ;
deque <ll> p , pe ;
ll a , b , c , d , e , f , cnt , ans , r , n ;
ld q , t ;
string g , h , w , o , z , m ;
char y , u ;
int main ()
{
    bzbz
    mlojins
    CODER
    cin >> a ;
    for (int i = 0 ; i < a ; i ++ )
    {
        cin >> b ;
        v.pb(b);
    }
    for (int i = 0 ; i < v.size() ; i ++ )
    {
        cnt = 0 ;
        for (int j = 0 ; j < v.size() ; j ++ )
        {
            if (v[j] % v[i] == 0)
                cnt ++ ;
        }
        if (cnt == v.size())
        {
            cout << v[i] ;
            return 0 ;
        }
    }
    cout << -1 ;
}


#include<bits/stdc++.h>
using namespace std;
int main(){

    long n;
    cin>>n;
    long a[n];
    long c=1e9;

    for(long k = 0; k < n; k++){
		cin>>a[k];
		if(a[k] < c){
			c = a[k];
		}
	}
    for(long k = 0; k < n; k++){
		if(a[k] % c != 0){
		c = -1; break;
		}
	}
    cout<<c<<endl;
    return 0;
}


#include <cstdio>

int main(){

    long n(0); scanf("%ld\n", &n);
    long *array = new long[n];
    long currentMin(1e9);
    for(long k = 0; k < n; k++){scanf("%ld", array + k); if(array[k] < currentMin){currentMin = array[k];}}
    for(long k = 0; k < n; k++){if(array[k] % currentMin != 0){currentMin = -1; break;}}
    printf("%ld\n", currentMin);
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
int main (void)
{

    int n,i,arr[100001],m;
    bool k;

    while (scanf ("%d",&n) != EOF)
    {
        for (i=0; i<n; i++)
            scanf ("%d",&arr[i]);

        sort (arr,arr+i);

        m = arr[0];
        k = true;

        for (i=0; i<n; i++)
        {
            if (arr[i] % m != 0)
            {
                k = false;
                break;
            }
        }

        if (k)
            printf ("%d\n",m);
        else
            printf ("-1\n");
    }

    return 0;
}


#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n,min1,i,count=0;
    scanf("%d",&n);
    long long int arr[100001];
    for(i=0; i<n; i++)
    {
        scanf("%d",&arr[i]);

    }
    sort(arr,arr+n);
    min1=arr[0];
    bool k=true;
    for(i=0; i<n; i++)
    {
        if(arr[i]%min1==0)
        {
            k=false;
            break;
        }
    }
    if(k)
    {
        printf("%d\n",min1);
    }
    else
    {
        printf("-1");
    }

}


    #include<stdio.h>
    main()
    {
        long long int n,min=999999999,i,count=0;
        scanf("%lld",&n);
        long long int arr[100000];
        for(i=0; i<n; i++)
        {
            scanf("%lld",&arr[i]);
            if(arr[i]<min)
            {
                min=arr[i];
            }

        }
        for(i=0; i<n; i++)
        {
            if(arr[i]%min!=0)
            {
              count++;
            }
            else
            {
         count=0;
            }
        }
        if(count==0)
        {
            printf("%d\n",min);
        }
        else
        {
            printf("-1\n");
        }

    }


    #include<stdio.h>
    main()
    {
        long long int n,min=9000000000,i,count=0;
        scanf("%lld",&n);
        long long int arr[100000];
        for(i=0; i<n; i++)
        {
            scanf("%lld",&arr[i]);
            if(arr[i]<min)
            {
                min=arr[i];
            }

        }
        for(i=0; i<n; i++)
        {
            if(arr[i]%min!=0)
            {
              count++;
            }
            else
            {
         count=0;
            }
        }
        if(count==0)
        {
            printf("%d\n",min);
        }
        else
        {
            printf("-1\n");
        }

    }


#include<stdio.h>
main()
{
    int n,min=100000000,i,count=0;
    scanf("%d",&n);
    int arr[100000];
    for(i=0; i<n; i++)
    {
        scanf("%d",&arr[i]);
        if(arr[i]<min)
        {
            min=arr[i];
        }

    }
    for(i=0; i<n; i++)
    {
        if(arr[i]%min!=0)
        {
          count++;
        }
        else
        {
     count=0;
        }
    }
    if(count==0)
    {
        printf("%d",min);
    }
    else
    {
        printf("-1");
    }

}


    #include<stdio.h>
    main()
    {
        long long int n,min=900000000,i,count=0;
        scanf("%lld",&n);
        long long int arr[100000];
        for(i=0; i<n; i++)
        {
            scanf("%lld",&arr[i]);
            if(arr[i]<min)
            {
                min=arr[i];
            }

        }
        for(i=0; i<n; i++)
        {
            if(arr[i]%min!=0)
            {
              count++;
            }
            else
            {
         count=0;
            }
        }
        if(count==0)
        {
            printf("%d",min);
        }
        else
        {
            printf("-1");
        }

    }


    #include<stdio.h>
    main()
    {
        long long int n,min=999999999,i,count=0;
        scanf("%lld",&n);
        long long int arr[100000];
        for(i=0; i<n; i++)
        {
            scanf("%lld",&arr[i]);
            if(arr[i]<min)
            {
                min=arr[i];
            }

        }
        for(i=0; i<n; i++)
        {
            if(arr[i]%min!=0)
            {
              count++;
            }
            else
            {
         count=0;
            }
        }
        if(count==0)
        {
            printf("%lld\n",min);
        }
        else
        {
            printf("-1\n");
        }

    }


/*
Md Siamul Islam
University:North South University
handle:traveller42

 */
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
vector <int>myvec;
map<int,int>mymap;
set<int>s;
int main()
{
 ll n,in;
 cin >> n;
   for(int i=1;i<=n;i++){
       cin >> in;
       myvec.push_back(in);
       s.insert(in);
         }
         int flag=0;
    set<int>::iterator it;
    for(it=s.begin(); it!=s.end();it++){
        for(ll i=0;i<myvec.size();i++){
                 if(myvec[i]% *it==0){
                     flag=1;
                     }
                   else{
                         flag=0;
                         break;
                         }

                 }
          if(flag==1){
               cout << *it<<endl;
               return 0;
               }
           else
           continue;
        }
      cout<<"-1"<<endl;

    return 0;
}


/*
Md Siamul Islam
University:North South University
handle:traveller42

 */
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
vector <ll>myvec;
map<int,int>mymap;
set<ll>s;
int main()
{
 ll n,in;
 cin >> n;
   for(ll i=1;i<=n;i++){
       cin >> in;
       myvec.push_back(in);
       s.insert(in);
         }
         int flag=0;
    set<ll>::iterator it;
    for(it=s.begin(); it!=s.end();it++){
        for(ll i=0;i<myvec.size();i++){
                 if(myvec[i]% *it==0){
                     flag=1;
                     }
                   else{
                         flag=0;
                         break;
                         }

                 }
          if(flag==1){
               cout << *it<<endl;
               return 0;
               }
           else
           continue;
        }
      cout<<"-1"<<endl;

    return 0;
}


#include <bits/stdc++.h>
using namespace std;
int n,a[1000005],Gcd;
bool t;
int main() {
	cin>>n;cin>>a[1];Gcd=a[1];
	for(int i=2;i<=n;i++){
		cin>>a[i];
		Gcd=__gcd(Gcd,a[i]);
	}
	for(int i=1;i<=n;i++){
		if(a[i]==Gcd){
			t=true;
			break;
		}
	}
	if(t)cout<<Gcd;
	else cout<<-1;
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
int a[100001];
int main() {
	int n;
	cin>>n;
	cin>>a[1];
	int p=a[1],ans=0;
	for(int i=2;i<=n;++i)
	{
		cin>>a[i];
		p=__gcd(p,a[i]);
	}
	for(int i=1;i<=n;++i)
	{
		if(a[i]==p)
		{
			ans++;
			cout<<a[i];
			return 0;
		}
	}
	if(ans==0) cout<<-1;
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
int gcd(int x,int y)
{
	if(y==0)
	return x;
	return gcd(y,x%y);
}
int main()
{
	int n,k;
	cin>>n;
	int a[n+5];
	for(int i=1;i<=n;i++)
	cin>>a[i];
	k=a[1];
	for(int i=2;i<=n;i++)
	k=gcd(k,a[i]);
	for(int i=1;i<=n;i++)
	{
		if(a[i]==k)
		{
			cout<<k;
			return 0;
		}
	}
	cout<<-1;
	return 0;
}


// luogu-judger-enable-o2
#include<cstdio>
using namespace std;
long long n,m,w[100010],ans=100000010;
long long MIN(long long x,long long y){ return x > y ? y : x; }
inline void read(long long& ret) {
    ret=0;int f=1;char ch=getchar();
    while (ch<'0'||ch>'9') {if (ch=='-') f=-f;ch=getchar();}
    while (ch>='0'&&ch<='9') ret=ret*10+ch-'0',ch=getchar();
    ret*=f;
}
int main()
{
   int i;
   read(n);
   for(i=1;i<=n;i++){
      read(w[i]);
      ans = MIN(ans,w[i]);
   }
   for(i=1;i<=n;i++){
      if(w[i]%ans != 0){
         printf("1");
         return 0;
      }
   }
   printf("%d",ans);
   return 0;
}


#include<iostream>
using namespace std;
int n,a[100005],gcd;
int GCD(int x,int y){
	if(y==0)return x;
	return GCD(y,x%y);
}
int main()
{
    cin>>n;
    for(int i=1;i<=n;i++) scanf("%d",&a[i]);
    gcd=a[1];
    for(int i=2;i<=n;i++) gcd=GCD(gcd,a[i]);
    for(int i=1;i<=n;i++)
    {
        if(a[i]==gcd)
        {
            cout<<a[i];
            return 0;
        }
    }
    cout<<-1;
    return 0;
}


#include<cstdio>
#include<algorithm>
#define maxn 10005
using namespace std;
int a[maxn];
int n,Gcd;
bool flag=0;
int gcd(int a, int b){
	if(b==0) return a;
	else return gcd(b,a%b);
}
int main(){
	scanf("%d",&n);
	scanf("%d",&a[1]);
	Gcd=a[1];
	for(int i=2; i<=n; i++){
	    scanf("%d",&a[i]);
	    Gcd=gcd(Gcd,a[i]);
    }
    for(int i=1; i<=n; i++)
    	if(Gcd%a[i]==0){
    		flag=1;
    		printf("%d",a[i]);
    		break;
		}
	if(flag==0) printf("-1");
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
int a[100010];
int main()
{
    int n;
    cin >> n;
    for (int i = 0; i < n; i++ )
        cin>>a[i];
    int gcd=a[0];
    for (int i=1; i < n; i++ )
        gcd=__gcd( a[i], gcd);
    for (int i = 0; i < n; i++ )
        if (gcd==a[i])
        {
            cout<<a[i]<<endl;
            return 0;
        }
    cout<<-1<< endl;
}


#include<iostream>
#include<stdio.h>
#include<stdlib.h>
#include<algorithm>
using namespace std;
int a[1000001];
bool cmp(int a,int b)
{
    return a<b;
}
int main()
{
    int n;
    scanf("%d",&n);
    register int i;
    for(i=1;i<=n;++i)
        scanf("%d",&a[i]);
    sort(a+1,a+1+n,cmp);
    int k=a[1];
    for(i=1;i<=n;++i)
    {
        if(a[i]%k!=0)
        {
            printf("-1");
            return 0;
        }
    }
    printf("%d",k);
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin >> n;
    int a[n] ;
    for(int i=0;i<n;i++)
    {
        cin >> a[i] ;
    }
    sort(a,a+n);
    int t = a[0] ;
    for(int i=1;i<n;i++)
    {
        if(a[i]%t != 0)
        {
            cout << "-1" << endl;
            return 0;
        }
    }
    cout << t << endl;
    return 0;
}


#include<iostream>
using namespace std;
int main()
{
    int n ;
    cin >> n;
    int a[n];
    for(int i=0;i<n;i++)
    {
        cin >> a[i] ;
        if(a[i] == 1)
        {
            cout << "1" << endl;
            return 0;
        }
    }
    for(int i=0;i<n;i++)
    {
        int ans = 0 ;
        for(int j=i+1;j<n;j++)
        {
            if(a[j] % a[i] == 0)
            {
                ans++ ;
            }
        }
        if(ans == n)
        {
            cout << a[i] << endl;
            return 0;
        }
    }
    cout << "-1" << endl;
    return 0;
}


#include<iostream>
using namespace std;
int main()
{
    int n ;
    cin >> n;
    int a[n];
    for(int i=0;i<n;i++)
    {
        cin >> a[i] ;
        if(a[i] == 1)
        {
            cout << "1" << endl;
            return 0;
        }
    }
    for(int i=0;i<n;i++)
    {
        int ans = 0 ;
        for(int j=0;j<n;j++)
        {
            if(a[j] % a[i] != 0)
            {
                cout << "-1" << endl;
                return 0;
            }
            else
            {
                ans++ ;
            }
        }
        if(ans == n)
        {
            cout << a[i] << endl;
            return 0;
        }
    }
}


#include<iostream>
using namespace std;
int main()
{
    int n ;
    cin >> n;
    int a[n];
    for(int i=0;i<n;i++)
    {
        cin >> a[i] ;
        if(a[i] == 1)
        {
            cout << "1" << endl;
            return 0;
        }
    }
    for(int i=0;i<n;i++)
    {
        int ans = 0 ;
        for(int j=0;j<n;j++)
        {
            if(a[j] % a[i] == 0)
            {
                ans++ ;
            }
        }
        if(ans == n)
        {
            cout << a[i] << endl;
            return 0;
        }
    }
    cout << "-1" << endl;
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;

#if !defined ONLINE_JUDGE || defined LOCAL
__attribute__((destructor)) static void __destroy__() { cerr << "\nTime elapsed: " << (double)clock() / CLOCKS_PER_SEC << "s.\n"; }

void debug(){}
template<class t, class... u> void debug(t x, u ...y){ cerr << ' ' << x, debug(y...); }
#define debug(x...) cerr << "\x1b[91m[" #x "] =", debug(x), cerr << "\x1b[0m\n"
#else
#define assert(x) void(0)
#define debug(...) void(0)
#define freopen(...) void(0)
#endif

#define gcd __gcd
#define endl '\n'
#define st first
#define nd second
#define pb push_back
#define zero(x) (abs(x) < eps)
#define pi acos(-1.0l)
#define inf 0x3f3f3f3f
#define infl 0x3f3f3f3f3f3f3f3f

#define popcnt __builtin_popcountll
#define ctz __builtin_ctzll
int clz(int x){ return __builtin_clz(x); }
int clz(long x){ return __builtin_clzl(x); }
int clz(long long x){ return __builtin_clzll(x); }

#define y0 asdf1
#define y1 asdf2
#define yn asdf3
#define j1 asdf4
#define tm asdf5
#define lr asdf6
#define div asdf7

template<class t1, class t2, class t3> struct triple{
  t1 st; t2 nd; t3 rd;

  triple() : st(), nd(), rd() {}
  triple(const t1& a, const t2& b, const t3& c) : st(a), nd(b), rd(c) {}

  bool operator == (const triple& t) const { return st == t.st && nd == t.nd && rd == t.rd; }
  bool operator != (const triple& t) const { return !(*this == t); }
  bool operator <  (const triple& t) const { return st != t.st ? st < t.st : nd != t.nd ? nd < t.nd : rd < t.rd; }
  bool operator <= (const triple& t) const { return !(t < *this); }
  bool operator >  (const triple& t) const { return t < *this; }
  bool operator >= (const triple& t) const { return !(*this < t); }
};

template<class t> using tset = tree<t,null_type,less<t>,rb_tree_tag,tree_order_statistics_node_update>;
template<class t,class u> using tmap = tree<t,u,less<t>,rb_tree_tag,tree_order_statistics_node_update>;
template<class t,class u = greater<t>> using pqueue = priority_queue<t,vector<t>,u>;

template<class t1, class t2> ostream& operator << (ostream& out, const pair<t1,t2>& x){ return out << '(' << x.st << ", " << x.nd << ')'; }
template<class t1, class t2, class t3> ostream& operator << (ostream& out, const triple<t1,t2,t3>& x){ return out << '(' << x.st << ", " << x.nd << ", " << x.rd << ')'; }

#define PRINT_DS bool flag = 0; out << '['; for(auto& x : ds){ if(flag) out << ", "; else flag = 1; out << x; } return out << ']'
template<class t> ostream& operator << (ostream& out, const vector<t>& ds){ PRINT_DS; }
template<class t> ostream& operator << (ostream& out, const set<t>& ds){ PRINT_DS; }
template<class t> ostream& operator << (ostream& out, const tset<t>& ds){ PRINT_DS; }
template<class t1, class t2> ostream& operator << (ostream& out, const map<t1,t2>& ds){ PRINT_DS; }
template<class t1, class t2> ostream& operator << (ostream& out, const tmap<t1,t2>& ds){ PRINT_DS; }

typedef long long ll;
typedef unsigned long long ull;
typedef long double lf;
typedef pair<int,int> ii;
typedef triple<int,int,int> tri;
typedef vector<int> vi;
typedef vector<ii> vii;

#define eps 1e-9
#define mod 1000000007
#define maxn 100010

int a[maxn];

int main(){
  freopen("in","r",stdin);
  cin.sync_with_stdio(0), cin.tie(0);

  int n;
  cin >> n;
  int m = inf;
  for(int i = 0; i < n; ++i){
    cin >> a[i];
    m = min(m, a[i]);
  }
  for(int i = 0; i < n; ++i){
    if(a[i] % m){
      cout << "-1\n";
      return 0;
    }
  }
  cout << m << endl;

  return 0;
}


#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;

#if !defined ONLINE_JUDGE || defined LOCAL
__attribute__((destructor)) static void __destroy__() { cerr << "\nTime elapsed: " << (double)clock() / CLOCKS_PER_SEC << "s.\n"; }

void debug(){}
template<class t, class... u> void debug(t x, u ...y){ cerr << ' ' << x, debug(y...); }
#define debug(x...) cerr << "\x1b[91m[" #x "] =", debug(x), cerr << "\x1b[0m\n"
#else
#define assert(x) void(0)
#define debug(...) void(0)
#define freopen(...) void(0)
#endif

#define gcd __gcd
#define endl '\n'
#define st first
#define nd second
#define pb push_back
#define zero(x) (abs(x) < eps)
#define pi acos(-1.0l)
#define inf 0x3f3f3f3f
#define infl 0x3f3f3f3f3f3f3f3f

#define popcnt __builtin_popcountll
#define ctz __builtin_ctzll
int clz(int x){ return __builtin_clz(x); }
int clz(long x){ return __builtin_clzl(x); }
int clz(long long x){ return __builtin_clzll(x); }

#define y0 asdf1
#define y1 asdf2
#define yn asdf3
#define j1 asdf4
#define tm asdf5
#define lr asdf6
#define div asdf7

template<class t1, class t2, class t3> struct triple{
  t1 st; t2 nd; t3 rd;

  triple() : st(), nd(), rd() {}
  triple(const t1& a, const t2& b, const t3& c) : st(a), nd(b), rd(c) {}

  bool operator == (const triple& t) const { return st == t.st && nd == t.nd && rd == t.rd; }
  bool operator != (const triple& t) const { return !(*this == t); }
  bool operator <  (const triple& t) const { return st != t.st ? st < t.st : nd != t.nd ? nd < t.nd : rd < t.rd; }
  bool operator <= (const triple& t) const { return !(t < *this); }
  bool operator >  (const triple& t) const { return t < *this; }
  bool operator >= (const triple& t) const { return !(*this < t); }
};

template<class t> using tset = tree<t,null_type,less<t>,rb_tree_tag,tree_order_statistics_node_update>;
template<class t,class u> using tmap = tree<t,u,less<t>,rb_tree_tag,tree_order_statistics_node_update>;
template<class t,class u = greater<t>> using pqueue = priority_queue<t,vector<t>,u>;

template<class t1, class t2> ostream& operator << (ostream& out, const pair<t1,t2>& x){ return out << '(' << x.st << ", " << x.nd << ')'; }
template<class t1, class t2, class t3> ostream& operator << (ostream& out, const triple<t1,t2,t3>& x){ return out << '(' << x.st << ", " << x.nd << ", " << x.rd << ')'; }

#define PRINT_DS bool flag = 0; out << '['; for(auto& x : ds){ if(flag) out << ", "; else flag = 1; out << x; } return out << ']'
template<class t> ostream& operator << (ostream& out, const vector<t>& ds){ PRINT_DS; }
template<class t> ostream& operator << (ostream& out, const set<t>& ds){ PRINT_DS; }
template<class t> ostream& operator << (ostream& out, const tset<t>& ds){ PRINT_DS; }
template<class t1, class t2> ostream& operator << (ostream& out, const map<t1,t2>& ds){ PRINT_DS; }
template<class t1, class t2> ostream& operator << (ostream& out, const tmap<t1,t2>& ds){ PRINT_DS; }

typedef long long ll;
typedef unsigned long long ull;
typedef long double lf;
typedef pair<int,int> ii;
typedef triple<int,int,int> tri;
typedef vector<int> vi;
typedef vector<ii> vii;

#define eps 1e-9
#define mod 1000000007
#define maxn "abacate"

vi div(int n){
  vi d;
  for(int i = 1; i * i <= n; ++i){
    if(n % i == 0){
      d.pb(i);
      if(n / i != i){
        d.pb(n / i);
      }
    }
  }
  return d;
}

int main(){
  freopen("in","r",stdin);
  cin.sync_with_stdio(0), cin.tie(0);

  int n;
  cin >> n;
  int g = 0;
  set<int> s;
  for(int i = 0, a; i < n; ++i){
    cin >> a;
    g = gcd(g, a);
    s.insert(a);
  }
  for(int d : div(g)){
    if(s.count(d)){
      cout << d << endl;
      return 0;
    }
  }
  cout << "-1\n";

  return 0;
}


#include<bits/stdc++.h>
using namespace std;
int a[100005];
int main()
{
	int n;
	cin>>n;
	for(int i=0;i<n;i++)
	cin>>a[i];
	if(n==1)
	{
	cout<<a[0]<<endl;
	return 0;}
	sort(a,a+n);
	if(a[1]%a[0]==0)
	cout<<a[0]<<endl;
	else
	cout<<"-1"<<endl;
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
int a[100005];
int main()
{
	int n;
	cin>>n;
	for(int i=0;i<n;i++)
	cin>>a[i];
	if(n==1)
	{
	cout<<a[0]<<endl;
	return 0;}
	sort(a,a+n);
	for(int i=1;i<n;i++)
	if(a[i]%a[0]!=0)
	{
	cout<<"-1"<<endl;
	return 0;}
	cout<<a[0]<<endl;
	return 0;
}


#include <iostream>
#include <stdio.h>
#include <cstring>
#include <cmath>
#include <climits>
#include <cstdlib>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <list>
#include <unordered_map>
#include <bitset>
#include <algorithm>
#define ll long long int
#define e() cout << endl;
#define MA INT_MAX
#define MI INT_MIN
#define MOD 1000000007;
#define ppi pair <int,int>
#define scn(n) scanf("%d",&n)
#define vvi(n,m,x) vector <vector <int> > v(n,vector <int> (m,x));
#define cp(x,y) cout << "Case : " << x << " " << y << endl;
using namespace std;
int main()
{
	int n,mx = 0,x = 0;
	cin >> n;
	int a[n];
	map <int,bool> mp;
	for(int i = 0;i < n;i++)
	{
		cin >> a[i];
		if(i)
			x = __gcd(a[i],x);
		else
			x = a[i];

		mx = max(mx,a[i]);
		mp[a[i]] = true;
	}
	if(x == 1 && !mp[x])
	{
		cout << "-1\n";
		return 0;
	}
	while(x <= mx)
	{
		if(mp[x])
		{
			cout << x << endl;
			return 0;
		}
		x += x;
	}
	cout << "-1\n";
	return 0;
}


#include <iostream>
#include <stdio.h>
#include <cstring>
#include <cmath>
#include <climits>
#include <cstdlib>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <list>
#include <unordered_map>
#include <bitset>
#include <algorithm>
#define ll long long int
#define e() cout << endl;
#define MA INT_MAX
#define MI INT_MIN
#define MOD 1000000007;
#define ppi pair <int,int>
#define scn(n) scanf("%d",&n)
#define vvi(n,m,x) vector <vector <int> > v(n,vector <int> (m,x));
#define cp(x,y) cout << "Case : " << x << " " << y << endl;
using namespace std;
int main()
{
	int n,mx = 0,x = 0;
	cin >> n;
	int a[n];
	map <int,bool> mp;
	for(int i = 0;i < n;i++)
	{
		cin >> a[i];
		if(i)
			x = __gcd(a[i],x);
		else
			x = a[i];

		mx = max(mx,a[i]);
		mp[a[i]] = true;
	}

	while(x <= mx)
	{
		if(mp[x])
		{
			cout << x << endl;
			return 0;
		}
		x += x;
	}
	cout << "-1\n";
	return 0;
}


#include <iostream>
#include <stdio.h>
#include <cstring>
#include <cmath>
#include <climits>
#include <cstdlib>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <list>
#include <unordered_map>
#include <bitset>
#include <algorithm>
#define ll long long int
#define e() cout << endl;
#define MA INT_MAX
#define MI INT_MIN
#define MOD 1000000007;
#define ppi pair <int,int>
#define scn(n) scanf("%d",&n)
#define vvi(n,m,x) vector <vector <int> > v(n,vector <int> (m,x));
#define cp(x,y) cout << "Case : " << x << " " << y << endl;
using namespace std;
int main()
{
	int n;
	cin >> n;
	int a[n],mi = INT_MAX;
	for(int i = 0;i < n;i++)
	{
		cin >> a[i];
		mi = min(a[i],mi);
	}

	for(int i = 0;i < n;i++)
	{
		if(a[i] % mi)
		{
			cout << "-1\n";
			return 0;
		}
	}
	cout << mi << endl;
}


#include <bits/stdc++.h>

using namespace std;

int main()
{

	bool o = false , e = false;
	int n  , mini;
	cin>>n;
	vector <int> v(n);
	for(int i = 0 ; i < n ; i++)
		{
			cin>>v[i];
			if(i == 0)mini = v[i];
            if(v[i] <= mini)mini = v[i];

			if((v[i] % 2 == 0)&& (v[i] % mini == 0))e = true;
			else if ((v[i] % 2 != 0 )&&( v[i] % mini !=0))o = true;
		}

	if (n == 1){ cout << v[0] << endl; }
    else{
        sort(v.begin(), v.end());
        if (v[0] == 1)
        {
        	cout<<1<<endl;
        }
        else{

	    	if (o == true && e == true){ cout << -1 << endl; }
	    	else if (o == true && e != true)cout<<v[0]<<endl;
	    	else if (o != true && e == true)cout<<v[0]<<endl;

    	}
	}

	return 0;
}


#include<iostream>
#include<string>
#include<algorithm>
#include<sstream>
#include<vector>
#include<algorithm>
using namespace std;
int main()
{
    int n; bool k = false;
    cin >> n;
    vector <int>v(n);
    for (int i = 0; i < n; i++)
        cin >> v[i];

    if (n == 1){ cout << v[0] << endl; }
    else{
        sort(v.begin(), v.end());
        int i;
        for (i = 1; i < n; i++){
            if (v[i] == v[i - 1])
            {
                i = i;
                k = true;
                break;
            }
            else k = false;
        }
        if (k == true){ cout << v[i] << endl; }
        else{ cout << -1 << endl; }

    }
    //system("pause");
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

int main()
{

	bool o = false , e = false;
	int n ;
	cin>>n;
	vector <int> v(n);
	for(int i = 0 ; i < n ; i++)
		{
			cin>>v[i];
			if(v[i] % 2 == 0 )e = true;
			else if (v[i] % 2 != 0)o = true;
		}

	if (n == 1){ cout << v[0] << endl; }
    else{
        sort(v.begin(), v.end());
        if (v[0] == 1)
        {
        	cout<<1<<endl;
        }
        else{

	    	if (o == true && e == true){ cout << -1 << endl; }

    	}
	}

	return 0;
}


#include<iostream>
#include<string>
#include<algorithm>
#include<sstream>
#include<vector>
#include<algorithm>
using namespace std;
int main()
{
    int n; bool k = false;
    cin >> n;
    vector <int>v(n);
    for (int i = 0; i < n; i++)
        cin >> v[i];

    if (n == 1){ cout << v[0] << endl; }
    else{
        sort(v.begin(), v.end());
        int i;
        for (i = 1; i < n; i++)
            if (v[i] == v[i - 1])
            {
            i = i;
            k = true;
            break;
            }

        if (k == true){ cout << v[i] << endl; }
        else{ cout << -1 << endl; }

    }
    //system("pause");
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

int main()
{

	bool o = false , e = false;
	int n  , mini;
	cin>>n;
	vector <int> v(n);
	for(int i = 0 ; i < n ; i++)
		{
			cin>>v[i];
			if(i == 0)mini = v[i];
            if(v[i] < mini)mini = v[i];

		}

        sort(v.begin(), v.end());

	    for(int i = 0 ; i < n ; i++){
            	if(v[i] % mini == 0)e = true;
			else if
                ( v[i] % mini !=0)o = true;

	    }
	    	if (o == true && e == true){ cout << -1 << endl; }
	    	else if (o == true && e != true)cout<<mini<<endl;
	    	else if (o != true && e == true)cout<<mini<<endl;

	return 0;
}


#include <bits/stdc++.h>

using namespace std;

int main()
{

	bool o = false , e = false;
	int n ;
	cin>>n;
	vector <int> v(n);
	for(int i = 0 ; i < n ; i++)
		{
			cin>>v[i];
			if(v[i] % 2 == 0 )e = true;
			else if (v[i] % 2 != 0)o = true;
		}

	if (n == 1){ cout << v[0] << endl; }
    else{
        sort(v.begin(), v.end());
        if (v[0] == 1)
        {
        	cout<<1<<endl;
        }
        else{

	    	if (o == true && e == true){ cout << -1 << endl; }
	    	else if (o == true && e != true)cout<<v[0]<<endl;
	    	else if (o != true && e == true)cout<<v[0]<<endl;

    	}
	}

	return 0;
}


#include<iostream>
#include<string>
#include<algorithm>
#include<sstream>
#include<vector>
#include<algorithm>
using namespace std;
int main()
{
    int n; bool k = false;
    cin >> n;
    vector <int>v(n);
    for (int i = 0; i < n; i++)
        cin >> v[i];
    sort(v.begin(), v.end());
    int i;
    for ( i = 1; i < n; i++)
        if (v[i] == v[i - 1])
        {
        i = i;
        k = true;
        break;
        }

    if (k == true){ cout << v[i] << endl; }
    else{ cout << -1 << endl; }
    //system("pause");
    return 0;
}


#include<iostream>
#include<math.h>
#include<map>
#include<string>
#include<queue>
#include<stack>
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<set>
long int a[100001];
using namespace std;
int main()
{
	ios_base::sync_with_stdio(0);
	int n;
	cin >> n;
	long int min = 1000000000;
	if (n == 1)
	{
		cin >> n;
		cout << n;
		return 0;
	}
	for (int i = 0; i < n; i++)
	{
		cin >> a[i];
		if (a[i] < min)
			min = a[i];
	}
		for (int j = 0; j < n; j++)
		{
			if (a[j] %min != 0)
			{
				cout << -1;
				return 0;
			}
		}

	cout << min;
	return 0;
}


#include<iostream>
#include<math.h>
#include<map>
#include<string>
#include<queue>
#include<stack>
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<set>
int a[100001];
using namespace std;
void check(int i)
{

}
int main()
{
	ios_base::sync_with_stdio(0);
	int n;
	cin >> n;
	bool flag, f;
	if (n == 1)
	{
		cin >> n;
		cout << n;
		return 0;
	}
	for (int i = 0; i < n; i++)
	{
		cin >> a[i];
		if (a[i] == 1)
		{
			cout << 1;
			return 0;
		}
	}
	sort(a, a + n);
	for (int i = 0; i <2; i++)
	{
		flag = true;
		for (int j = i+1; j < n; j++)
		{
			if (a[j] % a[i] != 0)
			{
				flag = false;
				break;
			}
		}
		if (flag)
		{
			cout << a[i];
			return 0;
		}
	}
	cout << -1;
	return 0;
}


#include<iostream>
#include<math.h>
#include<map>
#include<string>
#include<queue>
#include<stack>
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<set>
long int a[100001];
using namespace std;
int main()
{
	ios_base::sync_with_stdio(0);
	int n;
	cin >> n;
	long int min = 100000000;
	if (n == 1)
	{
		cin >> n;
		cout << n;
		return 0;
	}
	for (int i = 0; i < n; i++)
	{
		cin >> a[i];
		if (a[i] < min)
			min = a[i];
	}
		for (int j = 0; j < n; j++)
		{
			if (a[j] %min != 0)
			{
				cout << -1;
				return 0;
			}
		}

	cout << min;
	return 0;
}


#include<iostream>
#include<math.h>
#include<map>
#include<string>
#include<queue>
#include<stack>
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<set>
int a[100001];
using namespace std;
void check(int i)
{

}
int main()
{
	ios_base::sync_with_stdio(0);
	int n;
	cin >> n;
	bool flag, f;
	for (int i = 0; i < n; i++)
	{
		cin >> a[i];
		if (a[i] == 1)
		{
			cout << 1;
			return 0;
		}
	}
	sort(a, a + n);
	for (int i = 0; i < n; i++)
	{
		flag = true;
		f = false;
		for (int j = i+1; j < n-1; j++)
		{
			if (a[j] % a[i] != 0)
			{
				flag = false;
				break;
			}
		}
		if (flag)
		{
			cout << a[i];
			return 0;
		}
	}
	cout << -1;
	return 0;
}


#include<iostream>
#include<math.h>
#include<map>
#include<string>
#include<queue>
#include<stack>
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<set>
int a[100001];
using namespace std;
int main()
{
	ios_base::sync_with_stdio(0);
	int n;
	cin >> n;
	bool flag;
	if (n == 1)
	{
		cin >> n;
		cout << n;
		return 0;
	}
	for (int i = 0; i < n; i++)
	{
		cin >> a[i];
	}
	sort(a, a + n);
		flag = true;
		for (int j = 1; j < n; j++)
		{
			if (a[j] % a[0] != 0)
			{
				flag = false;
				break;
			}
		}
		if (flag)
		{
			cout << a[0];
			return 0;
		}

	cout << -1;
	return 0;
}


#include<iostream>
#include<math.h>
#include<map>
#include<string>
#include<queue>
#include<stack>
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<set>
long int a[100001];
using namespace std;
int main()
{
	ios_base::sync_with_stdio(0);
	int n;
	cin >> n;
	long int min = 100000000;
	if (n == 1)
	{
		cin >> n;
		cout << n;
		return 0;
	}
	for (int i = 0; i < n; i++)
	{
		cin >> a[i];
		if (a[i] < min)
			min = a[i];
	}
		for (int j = 0; j < n; j++)
		{
			if (a[j] % a[0] != 0)
			{
				cout << -1;
				return 0;
			}
		}

	cout << min;
	return 0;
}


#include<iostream>
#include<math.h>
#include<map>
#include<string>
#include<queue>
#include<stack>
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<set>
int a[100001];
using namespace std;
void check(int i)
{

}
int main()
{
	ios_base::sync_with_stdio(0);
	int n;
	cin >> n;
	bool flag, f;
	if (n == 1)
	{
		cin >> n;
		cout << n;
		return 0;
	}
	for (int i = 0; i < n; i++)
	{
		cin >> a[i];
		if (a[i] == 1)
		{
			cout << 1;
			return 0;
		}
	}
	sort(a, a + n);
	for (int i = 0; i < n-1; i++)
	{
		flag = true;
		for (int j = i+1; j < n; j++)
		{
			if (a[j] % a[i] != 0)
			{
				flag = false;
				break;
			}
		}
		if (flag)
		{
			cout << a[i];
			return 0;
		}
	}
	cout << -1;
	return 0;
}


#include<iostream>
#include<math.h>
#include<map>
#include<string>
#include<queue>
#include<stack>
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<set>
int a[100001];
using namespace std;
void check(int i)
{

}
int main()
{
	ios_base::sync_with_stdio(0);
	int n;
	cin >> n;
	bool flag;
	for (int i = 0; i < n; i++)
	{
		cin >> a[i];
		if (a[i] == 1)
		{
			cout << 1;
			return 0;
		}
	}
	for (int i = 0; i < n; i++)
	{
		flag = true;
		for (int j = 0; j < n; j++)
		{
			if (a[j] % a[i] != 0)
			{
				flag = false;
				break;
			}
		}
		if (flag)
		{
			cout << a[i];
			return 0;
		}
	}
	cout << -1;
	return 0;
}


#include<iostream>
#include<math.h>
#include<map>
#include<string>
#include<queue>
#include<stack>
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<set>
int a[100001];
using namespace std;
void check(int i)
{

}
int main()
{
	ios_base::sync_with_stdio(0);
	int n;
	cin >> n;
	bool flag, f;
	for (int i = 0; i < n; i++)
	{
		cin >> a[i];
		if (a[i] == 1)
		{
			cout << 1;
			return 0;
		}
	}
	sort(a, a + n);
	for (int i = 0; i < n-1; i++)
	{
		flag = true;
		for (int j = i+1; j < n; j++)
		{
			if (a[j] % a[i] != 0)
			{
				flag = false;
				break;
			}
		}
		if (flag)
		{
			cout << a[i];
			return 0;
		}
	}
	cout << -1;
	return 0;
}


//In C<>de We Trust :D
#include <bits/stdc++.h>

using namespace std;

#define MohammadAmin main()
#define ll long long
#define pii pair<int, int>
#define pll pair<ll, ll>
#define pcc pair<char, char>
#define mpair make_pair
#define endl "\n"
#define c_false ios_base::sync_with_stdio(false)
#define pushb push_back
#define pushf push_front
#define popb pop_back
#define popf pop_front
#define sz size()
#define X first
#define Y second
#define ashar(a) cout << fixed << setprecision((a))
#define reset(a,b) memset(a, b, sizeof(a))
#define min(x, y) (x < y ? x : y)
#define max(x, y) (x > y ? x : y)
const ll INF = 1e9;
ll gcd (ll a, ll b) {return ( a ? gcd(b%a, a) : b );}
ll power(ll a, ll n) {ll p = 1;while (n > 0) {if(n%2) {p = p * a;} n >>= 1; a *= a;} return p;}

int MohammadAmin {
	c_false;
	int n, a[100010];
	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		scanf("%d", a+i);
	}
	sort(a, a+n);
	for (int i = 0; i < n; i++) {
		if (a[i] % a[0]) {
			printf("-1");
			//cerr << "\t" << i;
			return 0;
		}
	}
	printf("%d", a[0]);
	return 0;
}


//In C<>de We Trust :D
#include <bits/stdc++.h>

using namespace std;

#define MohammadAmin main()
#define ll long long
#define pii pair<int, int>
#define pll pair<ll, ll>
#define pcc pair<char, char>
#define mpair make_pair
#define endl "\n"
#define c_false ios_base::sync_with_stdio(false)
#define pushb push_back
#define pushf push_front
#define popb pop_back
#define popf pop_front
#define sz size()
#define X first
#define Y second
#define ashar(a) cout << fixed << setprecision((a))
#define reset(a,b) memset(a, b, sizeof(a))
#define min(x, y) (x < y ? x : y)
#define max(x, y) (x > y ? x : y)
const ll INF = 1e9;
ll gcd (ll a, ll b) {return ( a ? gcd(b%a, a) : b );}
ll power(ll a, ll n) {ll p = 1;while (n > 0) {if(n%2) {p = p * a;} n >>= 1; a *= a;} return p;}

int MohammadAmin {
	c_false;
	int n, a[100010], mn = 1000000010;
	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		scanf("%d", a+i);
		mn = min(mn, a[i]);
	}
	for (int i = 0; i < n; i++) {
		if (a[i] % n == 0) {
			printf("-1");
			//cerr << "\t" << i;
			return 0;
		}
	}
	printf("%d", mn);
	return 0;
}


//In C<>de We Trust :D
#include <bits/stdc++.h>

using namespace std;

#define MohammadAmin main()
#define ll long long
#define pii pair<int, int>
#define pll pair<ll, ll>
#define pcc pair<char, char>
#define mpair make_pair
#define endl "\n"
#define c_false ios_base::sync_with_stdio(false)
#define pushb push_back
#define pushf push_front
#define popb pop_back
#define popf pop_front
#define sz size()
#define X first
#define Y second
#define ashar(a) cout << fixed << setprecision((a))
#define reset(a,b) memset(a, b, sizeof(a))
#define min(x, y) (x < y ? x : y)
#define max(x, y) (x > y ? x : y)
const ll INF = 1e9;
ll gcd (ll a, ll b) {return ( a ? gcd(b%a, a) : b );}
ll power(ll a, ll n) {ll p = 1;while (n > 0) {if(n%2) {p = p * a;} n >>= 1; a *= a;} return p;}

int MohammadAmin {
	c_false;
	int n, a[100010], mn = 1000000010;
	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		scanf("%d", a+i);
		mn = min(mn, a[i]);
	}
	if (n == 1) return printf("%d", a[0]), 0;
	for (int i = 0; i < n; i++) {
		if (a[i] % n == 0) {
			printf("-1");
			//cerr << "\t" << i;
			return 0;
		}
	}
	printf("%d", mn);
	return 0;
}


import java.util.*;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class SashaAndNames{

    static class FastReader
    {
        BufferedReader br;
        StringTokenizer st;

        public FastReader()
        {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String next()
        {
            while (st == null || !st.hasMoreElements())
            {
                try
                {
                    st = new StringTokenizer(br.readLine());
                }
                catch (IOException  e)
                {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt()
        {
            return Integer.parseInt(next());
        }

        long nextLong()
        {
            return Long.parseLong(next());
        }

        double nextDouble()
        {
            return Double.parseDouble(next());
        }

        String nextLine()
        {
            String str = "";
            try
            {
                str = br.readLine();
            }
            catch (IOException e)
            {
                e.printStackTrace();
            }
            return str;
        }
    }
    public static void main(String[] args){
        FastReader s = new FastReader();
        String str = s.next();
        HashSet<Character> set = new HashSet<>();
        for(int i = 0; i < str.length() / 2; i++){
            set.add(str.charAt(i));
        }
        if(set.size()==1 || str.length()==1){
            System.out.println("Impossible");
            return;
        }
        for(int i = 0;i<str.length()-1;i++){
            String temp = str.substring(i+1, str.length()) + str.substring(0, i+1);
            boolean ok = true;
            for(int c = 0;c<temp.length();c++){
                if(temp.charAt(c) != temp.charAt(temp.length()-c-1)){
                    ok = false;
                    break;
                }
            }

            if(ok && !temp.equals(str)){
                System.out.println("1");
                return;
            }

        }
        System.out.println("2");
    }

}