Under construction

Still being built. Things may change

Collatz Conjecture

Time limit10sMemory limit512 MB

Summary
Count how many distinct gcd values appear among all contiguous subarrays of the given sequence.
Level

Medium7 of 10

Topics
Array, Math, Number theory
Solved
No attempts yet

Problem

In 1978, while proving that P is a strict superset of NP, Sir Isaac Newton defined the Beta Alpha Pi Zeta function ff over an arbitrary sequence of positive integers a1,…,ana_1, \dots, a_n as follows. For integers ii, jj with 1≤i≤j≤n1 \le i \le j \le n, f(i,j)=gcd⁡(ai,ai+1,…,aj−1,aj)f(i, j) = \gcd(a_i, a_{i+1}, \dots, a_{j-1}, a_j).

About a century later Lothar Collatz applied this function to the sequence 1,1,1,…,11, 1, 1, \dots, 1 and observed that ff always equalled 1. From that he conjectured that ff is always a constant function, no matter what the sequence aia_i is. This claim, now known as the Collatz Conjecture, is one of the major open problems of botanical studies. (The Strong Collatz Conjecture says that however many values ff takes, the real part is always 1/21/2.)

You are a budding young cultural anthropologist and you have decided to disprove the conjecture. Given the sequence aia_i, count how many different values ff takes.

Input

The input consists of two lines.

The first line contains the length of the sequence nn (1≤n≤5×1051 \le n \le 5 \times 10^5).

The second line contains the sequence a1,a2,…,ana_1, a_2, \dots, a_n (1≤ai≤10181 \le a_i \le 10^{18}).

Output

Print a single line containing a single integer, the number of distinct values ff takes on over the given sequence.

Examples2

  1. Example 1

    Input
    4
    9 6 2 4
    
    Expected output
    6
    
  2. Example 2

    Input
    4
    9 6 3 4
    
    Expected output
    5