by poi
#include<iostream> #include<cstdio> #include<cstring> #include<algorithm> #include<vector> #include<map> #define N 1000003 #define p 200191 #define ll unsigned long long using namespace std; int n,m,a[N],maxn; ll s1[N],s2[N],mul[N]; vector<int> num; map<ll,int> mp; ll gethash(int l,int r) { if (l<=r) return s1[r]-s1[l-1]*mul[r-l+1]; else return s2[r]-s2[l+1]*mul[l-r+1]; } void solve (int x) { if (maxn*x>n) return; int ans=0; mp.clear(); for (int i=1;i<=n;i+=x) if (i+x-1<=n) { ll t=gethash(i,i+x-1)*gethash(i+x-1,i); if (!mp[t]) ans++,mp[t]=1; } if (ans>maxn) maxn=ans,num.clear(); if (ans==maxn) num.push_back(x); } int main() { scanf("%d",&n); for (int i=1;i<=n;i++) scanf("%d",&a[i]); mul[0]=1; for (int i=1;i<=n;i++) mul[i]=mul[i-1]*p; for (int i=1;i<=n;i++) s1[i]=s1[i-1]*p+a[i]; for (int i=n;i>=1;i--) s2[i]=s2[i+1]*p+a[i]; for (int i=1;i<=n;i++) solve(i); printf("%d %d\n",maxn,num.size()); for(int i=0;i<num.size();i++) if (i!=num.size()-1) printf("%d ",num[i]); else printf("%d\n",num[i]); }