use std::io::Read; fn run() { let mut s = String::new(); std::io::stdin().read_to_string(&mut s).unwrap(); let mut it = s.trim().split_whitespace(); it.next(); let a: Vec = it.map(|s| s.parse().unwrap()).collect(); let m = 300_000; let mut f: Vec = (0..=m).collect(); for i in 2.. { if i * i > m { break; } if f[i] == i { for j in i..=(m / i) { f[j * i] = i; } } } let mut dp = vec![0; m + 1]; for x in a { if x == 1 { dp[1] = 1; continue; } let mut d = vec![1]; let mut a = x; while a > 1 { let p = f[a]; let mut cnt = 0; while a % p == 0 { cnt += 1; a /= p; } let mut mul = 1; let len = d.len(); for _ in 0..cnt { mul *= p; for i in 0..len { let v = d[i] * mul; d.push(v); } } } for d in d { if d != x { dp[x] = std::cmp::max(dp[x], dp[d] + 1); } } } let ans = dp.into_iter().max().unwrap(); println!("{}", ans); } fn main() { run(); }