fn main() { let mut n = String::new(); std::io::stdin().read_line(&mut n).ok(); let n: usize = n.trim().parse().unwrap(); let mut a = String::new(); std::io::stdin().read_line(&mut a).ok(); let a: Vec = a.trim().split_whitespace().map(|s| s.parse().unwrap()).collect(); let mut maxvals = vec![0usize; 300001]; for &v in a.iter() { maxvals[v] = maxvals[v].max(1); if v == 1 { continue; } for i in 1..=(v as f64).sqrt().floor() as usize { if v % i == 0 { maxvals[v] = maxvals[v].max(maxvals[i]+1); if i > 1 { maxvals[v] = maxvals[v].max(maxvals[v/i]+1); } } } } println!("{}", maxvals.iter().max().unwrap()); }