Friend numbers P22662


Statement
 

pdf   zip

Let x1,,xnx_1, \dots, x_n be a non-empty sequence of natural numbers, all of them strictly larger than 1, and let gcd(x,y)gcd(x, y) stand as usual for the greatest common divisor of xx and yy. We say that xix_i is a friend of xjx_j if and only if at least one of these conditions hold:

  • gcd(xi,xj)>1gcd(x_i, x_j) > 1;

  • xix_i is a friend of some xkx_k, and xjx_j is also a friend of xkx_k.

Write a program such that, given a sequence of numbers, computes the size of the largest set of friends in it.

Input

Input consists of several cases. Every case begins with a number n1n \ge 1, followed by nn different integer numbers, all them between 2 and 100000.

Output

For every case, print the size of the largest set of friends.

Public test cases
  • Input

    4
    21 2 25 14
    3
    5 18 7
    

    Output

    3
    1
    
  • Information
    Author
    Salvador Roura
    Language
    English
    Official solutions
    C++
    User solutions
    C++