#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
using namespace std;
int ws[],wa[],wb[],sa[],x[],y[],h[],wv[],a[],b[],rank[];
int cmp(int *r,int a,int b,int l){return (r[a]==r[b])&&(r[a+l]==r[b+l]);}
void DA(int *r,int *sa,int n,int m)
{
int i,j,p,*x=wa,*y=wb,*t;
for(i=;i<m;i++)ws[i]=;
for(i=;i<n;i++)ws[x[i]=r[i]]++;
for(i=;i<m;i++)ws[i]+=ws[i-];
for(i=n-;i>=;i--)sa[--ws[x[i]]]=i;
for(j=,p=;p<n;j*=,m=p)
{
for(p=,i=n-j;i<n;i++)y[p++]=i;
for(i=;i<n;i++)if(sa[i]>=j)y[p++]=sa[i]-j;
for(i=;i<n;i++)wv[i]=x[y[i]];
for(i=;i<m;i++)ws[i]=;
for(i=;i<n;i++)ws[wv[i]]++;
for(i=;i<m;i++)ws[i]+=ws[i-];
for(i=n-;i>=;i--)sa[--ws[wv[i]]]=y[i];
for(t=x,x=y,y=t,p=,x[sa[]]=,i=;i<n;i++)
x[sa[i]]=cmp(y,sa[i-],sa[i],j)?p-:p++;
}
}
void calheight(int n)
{
int i,j,k=;
memset(rank,,sizeof(rank));
for(i=;i<n;i++)rank[sa[i]]=i;
for(i=;i<n;h[rank[i++]]=k)
for(k?k--:,j=sa[rank[i]-];b[i+k]==b[j+k];)
k++;
}
int solve(int o,int n)
{
int min,max,i;
max=-0x7fffffff;
min=0x7fffffff;
for(i=;i<=n;i++)
{
if(h[i]>=o)
{
if(sa[i]>max)max=sa[i];
if(sa[i]<min)min=sa[i];
if(max-min>=o)return ;
}
else
{
max=-0x7fffffff;
min=0x7fffffff;
if(sa[i]>max)max=sa[i];
if(sa[i]<min)min=sa[i];
}
}
if(max-min>=o)return ;
return ;
}
void ef(int low,int high,int n)
{
int mid;
while(low<high-)
{
mid=(low+high)/;
if(solve(mid,n)==)
{
low=mid;
}
else
{
high=mid;
}
}
if(low<)printf("0\n");
else printf("%d\n",low+);
}
int main()
{ int n,i,max,min;
while()
{
memset(ws,,sizeof(ws));
memset(wa,,sizeof(wa));
memset(wb,,sizeof(wb));
memset(sa,,sizeof(sa));
memset(h,,sizeof(h));
memset(wv,,sizeof(wv));
scanf("%d",&n);
if(n==)break;
for(i=;i<=n;i++)scanf("%d",&a[i]);
if(n<)
{
printf("0\n");
continue;
}
if(n==)
{
printf("0\n");
continue;
}
for(i=;i<=n-;i++)b[i-]=a[i+]-a[i]+;
b[n-]=;
n--;
max=-0x7fffffff;
min=0x7fffffff;
DA(b,sa,n+,);
calheight(n+);
max=-0x7fffffff;
min=0x7fffffff;
for(i=;i<n;i++)
{
if(h[i]>max)max=h[i];
if(h[i]<min)min=h[i];
}
ef(,n,n);
}
return ;
}