#Lutece2357. The Party

The Party

Migrated from Lutece 2357 The Party

All parts of this problem, including description, images, samples, data and checker, might be broken. If you find bugs in this problem, please contact the admins.

Description

2018 is about to end, 2019 is coming soon. Well, boys in UESTC, do you have girlfriends? Of course, bachelor XYZ is also worried about this problem. But now, he thinks of a good idea.

Tomorrow UESTC will hold a party, and XYZ is going to invite a girl whose name is Q to this party.

Q is a clever girl, she says: "Sure, but at first, you should solve my problem. If you can solve this problem, I will come with you and dance with you."

Here is the problem: Suppose there are nn people at the party, and everyone has a charm value. The ii-person's charm value is a[i]a[i]. Now, Q defines a function: f(k)f(k). The meaning of f(k)f(k) is as follows: We choose kk people from nn people, and the value of f(k)f(k) is equal to the Great Common Divisor of these kk people's charm value.

And Q wants the f(k)f(k) as large as possible. So now, she asks XYZ: "Can you calculate the f(k)f(k) when kk is from 11 to nn and kk is an integer?"

As we all know, XYZ is not good at math. Can you help him?

Note: Q wants the f(k)f(k) as large as possible when kk is from 11 to nn and kk is an integer.

Input

The first line contains an integer nn.

then nn lines are as follows: every line contains an integer a[i]a[i], which means i-person's charm value.

 n50000\ n\leq 50000, a[i]100000\ a[i]\leq 100000;

Output

There are nn lines, the i-th line outputs the f(k)f(k) when k=ik=i.

Note again: The f(k)f(k) should be maximized.

Samples

3
1
2
4
4
2
1

Note

f(1)=max{gcd(1),gcd(2),gcd(4)}=4f(1)=\max\{\gcd(1),\gcd(2),\gcd(4)\} =4 ;

f(2)=max{gcd(1,2),gcd(2,4),gcd(1,4)}=2f(2)=\max\{\gcd(1,2),\gcd(2,4),\gcd(1,4)\}=2;

f(3)=max{gcd(1,2,4)}=1f(3)=\max\{\gcd(1,2,4)\}=1;

Here is the gcd function :

int gcd(int a,int b){
    return b==0?a:gcd(b,a%b);
}

Resources

电子科技大学第十届ACM趣味程序设计竞赛