PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN

#GL0000126. Không thêm nữa (Not Adding)

HỌC THEO LỘ TRÌNH

Bài tập thuộc lộ trình

1 lộ trình

Không thêm nữa (Not Adding)

Not Adding

Source: Codeforces

Version: Phuoc Hung OJ Extended

Problem Statement

Initially, an array contains nn pairwise distinct positive integers. In one operation, choose elements at different indices and append their GCD to the array, provided that this GCD is not already present. Subsequent operations use the updated array. Determine the maximum possible number of operations.

Input

The first line contains nn; the second contains nn pairwise distinct positive integers.

Output

Print the maximum number of append operations.

Subtasks

  • Subtask 1 (20 points): 2≤n≤302\le n\le 30; 1≤ai≤1001\le a_i\le 100 và các aia_i đôi một khác nhau.
  • Subtask 2 (30 points): 2≤n≤2 0002\le n\le 2\,000; 1≤ai≤10 0001\le a_i\le 10\,000 và các aia_i đôi một khác nhau.
  • Subtask 3 (50 points): 2≤n≤1 000 0002\le n\le 1\,000\,000; 1≤ai≤1 000 0001\le a_i\le 1\,000\,000 và các aia_i đôi một khác nhau.

Examples

Input

5
4 20 1 25 30

Output

3

Explanation

Append 2 from gcd(4,30), 5 from gcd(20,25), and 10 from gcd(20,30). No other new value can be generated, so the answer is 3.