Geometric sequence

5

4 votes
Problem

Given a sequence a1an.
You need to find a subsequence ab1,ab2,,abm(b1<b2<<bm) and an integer k which satifies abi+1=kabi for all 1i<m.
Your goal is to maximize m.

Input

First line contains an integer n.

Second line contains n integers, representing the sequence a1an.

Output

An integer representing the maximum value of m.

Constraints

1n105

105ai105

Time Limit: 3
Memory Limit: 256
Source Limit:
Explanation

1,2,4 and 3,0,0 are two possible subsequences.

Editor Image

?