B. Lost Array

time limit per test

1 second

memory limit per test

256 megabytes

input

standard input

output

standard output

Bajtek, known for his unusual gifts, recently got an integer array x0,x1,…,xk−1x0,x1,…,xk−1.

Unfortunately, after a huge array-party with his extraordinary friends, he realized that he'd lost it. After hours spent on searching for a new toy, Bajtek found on the arrays producer's website another array aa of length n+1n+1. As a formal description of aa says, a0=0a0=0 and for all other ii (1≤i≤n1≤i≤n) ai=x(i−1)modk+ai−1ai=x(i−1)modk+ai−1, where pmodqpmodq denotes the remainder of division pp by qq.

For example, if the x=[1,2,3]x=[1,2,3] and n=5n=5, then:

  • a0=0a0=0,
  • a1=x0mod3+a0=x0+0=1a1=x0mod3+a0=x0+0=1,
  • a2=x1mod3+a1=x1+1=3a2=x1mod3+a1=x1+1=3,
  • a3=x2mod3+a2=x2+3=6a3=x2mod3+a2=x2+3=6,
  • a4=x3mod3+a3=x0+6=7a4=x3mod3+a3=x0+6=7,
  • a5=x4mod3+a4=x1+7=9a5=x4mod3+a4=x1+7=9.

So, if the x=[1,2,3]x=[1,2,3] and n=5n=5, then a=[0,1,3,6,7,9]a=[0,1,3,6,7,9].

Now the boy hopes that he will be able to restore xx from aa! Knowing that 1≤k≤n1≤k≤n, help him and find all possible values of kk — possible lengths of the lost array.

Input

The first line contains exactly one integer nn (1≤n≤10001≤n≤1000) — the length of the array aa, excluding the element a0a0.

The second line contains nn integers a1,a2,…,ana1,a2,…,an (1≤ai≤1061≤ai≤106).

Note that a0a0 is always 00 and is not given in the input.

Output

The first line of the output should contain one integer ll denoting the number of correct lengths of the lost array.

The second line of the output should contain ll integers — possible lengths of the lost array in increasing order.

Examples

input


5 1 2 3 4 5


output


5 1 2 3 4 5


input


5 1 3 5 6 8


output


2 3 5


input


3 1 5 3


output


1 3


Note

In the first example, any kk is suitable, since aa is an arithmetic progression.

Possible arrays xx:

  • [1][1]
  • [1,1][1,1]
  • [1,1,1][1,1,1]
  • [1,1,1,1][1,1,1,1]
  • [1,1,1,1,1][1,1,1,1,1]

In the second example, Bajtek's array can have three or five elements.

Possible arrays xx:

  • [1,2,2][1,2,2]
  • [1,2,2,1,2][1,2,2,1,2]

For example, k=4k=4 is bad, since it leads to 6+x0=86+x0=8 and 0+x0=10+x0=1, which is an obvious contradiction.

In the third example, only k=nk=n is good.

Array [1,4,−2][1,4,−2] satisfies the requirements.

Note that xixi may be negative.

 

 


分析:这题稍微一分析,还是能做的,a[i]的长度为n,b[i]=a[i] - a[i-1]=x[i] mod k,其中k为x的数组大小,让你求k的可能值,

我们可以看出肯定存在n个x[i]满足的,其实这个在某种程度也是唯一的(满足上述公式就行),x[i]是多少就无所谓,我们可以直接x[i]=b[i]+k,然后暴力求循环节就行了。

#include<cstdio>
#include <stdio.h>
#include <stdlib.h>
#include<cstring>
#include<cstdlib>
#include<cctype>
#include<cmath>
#include<iostream>
#include<sstream>
#include<iterator>
#include<algorithm>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<stack>
#include<deque>
#include<queue>
#include<list>
using namespace std;
const double eps = 1e-8;
typedef long long LL;
const int M=1005;
int n,m;
int a[M],b[M],x[M];
vector<int>ans;
int main()
{
scanf("%d",&n);

for(int i=1;i<=n;i++)
{
scanf("%d",&a[i]);
if(i>=2)
b[i]=a[i]-a[i-1];
else
b[i]=a[i];

}

int t;
for(int i=1;i<=n;i++)
{
t=b[i]+n;
x[i]=t;
}
for(int i=1;i<n;i++)
{
int flag=1;
int k=1;
for(int j=i+1;j<=n;j++)
{
if(x[k]!=x[j])
{
flag=0;
break;;
}
k++;
if(k>i)
k=1;
}
if(flag==1)
{
ans.push_back(i);
}
}
int l=ans.size();
cout<<l+1<<endl;
for(int i=0;i<l;i++)
{
cout<<ans[i]<<" ";
}
cout<<n<<endl;
return 0;
}