#include<bits/stdc++.h>
using namespace std;
#define maxn 1000100
int n,i,a[5500],j,ans,t;bool b[maxn];
int main()
{
scanf("%d",&n);
for(i=1;i<=n;i++)
scanf("%d",&a[i]);
i=n-1;
while (ans==0)
{
t=0;
for(j=0;j<=i;j++)
b[j]=false;
for(j=1;j<=n;j++)
{
if(b[a[j]%i]==true) {i++,t+=1;}
if(t==1) break;
b[a[j]%i]=true;
}
if (t==0) ans=i;
}
printf("%d",ans);
return 0;
}