AlgoUniversity
  • Go Back
Discussion
Divisor Friends :

Author

Lokesh

Difficulty Level : Easy

Submissions : 318

Asked In : saplabs

Marks :10

: 4 | : 1

There are $$$N$$$ students in the class, and each student has a favorite number $$$F_i$$$ given in the form of the array $$$F$$$.

$$$A$$$ Student is a friend of another student $$$B$$$ if at least one of these two conditions are satisfied

  • $$$gcd(A,B) > 1$$$
  • $$$A$$$ and $$$B$$$ have a common friend, ie $$$A$$$ is friend of $$$C$$$ and $$$B$$$ is also friend of $$$C$$$

Find the minimum number of groups that can be formed such that in a group, a member is friend with all other members.

A student belongs to exactly one group.

Input

The first line contains one integer $$$1 \le N \le 10^5$$$, denoting the number of students in the class.

The second line contain $$$N$$$ integers,$$$i^{th}$$$ denoting the favorite number of student $$$i$$$

Output

Output the minimum number of groups that can be formed such that in a group, a member is friend with all other members.

Examples

Input
4
2 4 6 5
Output
2
Input
4
2 6 3 21
Output
1

You need to login to view your submissions.

You need to login to view all submissions.

Loading...

Result : Executed

Loading...

Feel something is wrong with the test cases?

Result : Accepted

Test Cases :

You need to Log In
We're glad that you want to attempt this problem!

But to Run or Submit the Problem, you need to Log In.

Continue to Log In
Challenge Submitted!

Your challenge has been submitted successfully.

You will get a response soon via WhatsApp or Email.

Challenge
Facing issue while trying to solve the problem! Don't worry, we got you covered!

Do let us know your issue.

Looks good!
Please enter your issue / feedback.

How do we get in touch with you?
Looks good!
Please enter your phone no.
Looks good!
Please enter your email address.