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

#GL0000130. ƯCLN hoặc giá trị nhỏ hơn (GCD or MIN)

HỌC THEO LỘ TRÌNH

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

1 lộ trình

ƯCLN hoặc giá trị nhỏ hơn (GCD or MIN)

GCD or MIN

Source: AtCoder

Version: Phuoc Hung OJ Extended

Problem Statement

A blackboard initially holds nn positive integers. Perform exactly n−1n-1 operations: erase two present values x,yx,y and write back either gcd⁡(x,y)\gcd(x,y) or min⁡(x,y)\min(x,y). Count the number of distinct possible final integers over all valid operation sequences.

Input

The first line contains nn; the second contains the nn original values aia_i.

Output

Print the number of distinct possible last values.

Subtasks

  • Subtask 1 (20 points): 2≤n≤82\le n\le 8; 1≤ai≤1 0001\le a_i\le 1\,000.
  • Subtask 2 (30 points): 2≤n≤1002\le n\le 100; 1≤ai≤1 000 0001\le a_i\le 1\,000\,000.
  • Subtask 3 (50 points): 2≤n≤2 0002\le n\le 2\,000; 1≤ai≤1 000 000 0001\le a_i\le 1\,000\,000\,000.

Examples

Input

3
6 9 12

Output

2

Explanation

To obtain 3, replace (9,12) by gcd 3, then take min(6,3). To obtain 6, replace (6,12) by gcd 6, then take min(6,9). No other final values are possible.