POJ……啊 Exciting!
【英语能力渣看不懂题的我QwQ】
【而且<bits/stdc++.h>要CE不开心QwQ】
#include<cstdio>
#include<algorithm>
#include<iostream>
#include<cstring>
#define FLAZE_NAIVE
#define MAXN 40057
#define MAXM 180
#define INF 0x3f3f3f3f
using namespace std; int n;
struct t1{
int a[MAXN];
int son[MAXN][MAXM],pre[MAXN],dis[MAXN];
int cnt,lst;
int p,q,np,nq;
int L[MAXN],R[MAXN];
void insert(int x){
dis[np=++cnt]=dis[p=lst]+1;
L[np]=R[np]=dis[np];
lst=np;
for(;p&&!son[p][x];p=pre[p]) son[p][x]=np;
if(!p) return pre[np]=1,void();
q=son[p][x];
if(dis[p]+1==dis[q]) pre[np]=q;
else{
dis[nq=++cnt]=dis[p]+1;
memcpy(son[nq],son[q],sizeof son[q]);
pre[nq]=pre[q];
pre[q]=pre[np]=nq;
for(;p&&son[p][x]==q;p=pre[p]) son[p][x]=nq;
}
}
void build(){
for(int i=1;i<=n;++i) scanf("%d",a+i); --n;
for(int i=1;i<=n;++i) a[i]=a[i+1]-a[i]+88,insert(a[i]);
}
int ans;
int v[MAXN],s[MAXN];
void work(){
for(int i=1;i<=cnt;++i) ++v[dis[i]];
for(int i=1;i<=n;++i) v[i]+=v[i-1];
for(int i=1;i<=cnt;++i) s[v[dis[i]]--]=i;
int now;
for(int i=cnt;i;--i){
now=s[i];
R[ pre[now] ]=max(R[ pre[now] ],R[now]);
L[ pre[now] ]=min(L[ pre[now] ],L[now]);
}
for(int i=1;i<=cnt;++i)
ans=max(ans,min(dis[i],R[i]-L[i]));
ans=ans<4?0:ans+1;
// ++ans;
}
void init(){
memset(v,0,sizeof(v));
memset(L,INF,sizeof L);
memset(R,0,sizeof R);
memset(son,0,sizeof son);
memset(pre,0,sizeof pre);
cnt=lst=1;
ans=0;
}
#ifdef FLAZE_NAIVE
char tmp[MAXN];
void dfs(int now,int stp){
for(int i=0;i<26;++i)
if(son[now][i]){
tmp[stp]='a'+i;
puts(tmp);
dfs(son[now][i],stp+1);
}
tmp[stp]=0;
}
#endif
}SAM_s;
int main(){
while((~scanf("%d",&n))&&n){
SAM_s.init();
SAM_s.build();
SAM_s.work();
// SAM_s.dfs(1,0);
printf("%d\n",SAM_s.ans);
}
return 0;
}